1 karl 1.16 //%2005////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.13 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.10 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.13 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.16 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 mike 1.2 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
13 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
16 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
|
18 karl 1.16 //
|
19 mike 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
20 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
22 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Nag Boranna (nagaraja_boranna@hp.com)
31 //
32 // Modified By: Yi Zhou (yi_zhou@hp.com)
|
33 aruran.ms 1.19 // Dave Rosckes (rosckes@us.ibm.com)
34 // Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3614
|
35 vijay.eli 1.20 // Vijay Eli, IBM, (vijayeli@in.ibm.com) for Bug# 3613
|
36 aruran.ms 1.21 // Aruran, IBM (ashanmug@in.ibm.com) for Bug# 3613
|
37 david 1.6 //
|
38 mike 1.2 //%/////////////////////////////////////////////////////////////////////////////
39
40
41 ///////////////////////////////////////////////////////////////////////////////
|
42 chip 1.15 //
|
43 mike 1.2 // This file has implementation for the log property owner class.
44 //
45 ///////////////////////////////////////////////////////////////////////////////
46
47 #include "LogPropertyOwner.h"
|
48 david 1.6 #include <Pegasus/Common/Logger.h>
|
49 mike 1.2
50
51 PEGASUS_USING_STD;
52
53 PEGASUS_NAMESPACE_BEGIN
54
55 ///////////////////////////////////////////////////////////////////////////////
56 // LogPropertyOwner
57 ///////////////////////////////////////////////////////////////////////////////
58
59 static struct ConfigPropertyRow properties[] =
60 {
|
61 humberto 1.18 #if defined(PEGASUS_USE_RELEASE_CONFIG_OPTIONS) && !defined(PEGASUS_OS_OS400)
|
62 konrad.r 1.17 #if !defined(PEGASUS_USE_SYSLOGS)
|
63 konrad.r 1.14 {"logdir", "./logs", IS_DYNAMIC, 0, 0, IS_HIDDEN},
|
64 konrad.r 1.17 #endif
|
65 konrad.r 1.14 {"logLevel", "SEVERE", IS_DYNAMIC, 0, 0, IS_HIDDEN}
|
66 kumpf 1.11 #else
|
67 konrad.r 1.17 #if !defined(PEGASUS_USE_SYSLOGS)
|
68 konrad.r 1.14 {"logdir", "./logs", IS_DYNAMIC, 0, 0, IS_VISIBLE},
|
69 konrad.r 1.17 #endif
|
70 konrad.r 1.14 {"logLevel", "INFORMATION", IS_DYNAMIC, 0, 0, IS_VISIBLE}
|
71 kumpf 1.11 #endif
|
72 mike 1.2 };
73
74 const Uint32 NUM_PROPERTIES = sizeof(properties) / sizeof(properties[0]);
75
76
77 /** Constructors */
78 LogPropertyOwner::LogPropertyOwner()
79 {
|
80 konrad.r 1.17 #if !defined(PEGASUS_USE_SYSLOGS)
|
81 a.arora 1.12 _logdir.reset(new ConfigProperty);
|
82 konrad.r 1.17 #endif
|
83 a.arora 1.12 _logLevel.reset(new ConfigProperty);
|
84 mike 1.2 }
85
86
87 /**
88 Initialize the config properties.
89 */
90 void LogPropertyOwner::initialize()
91 {
92 for (Uint32 i = 0; i < NUM_PROPERTIES; i++)
93 {
94 //
95 // Initialize the properties with default values
96 //
|
97 konrad.r 1.17 #if !defined (PEGASUS_USE_SYSLOGS)
|
98 kumpf 1.8 if (String::equalNoCase(properties[i].propertyName, "logdir"))
|
99 mike 1.2 {
100 _logdir->propertyName = properties[i].propertyName;
101 _logdir->defaultValue = properties[i].defaultValue;
102 _logdir->currentValue = properties[i].defaultValue;
103 _logdir->plannedValue = properties[i].defaultValue;
104 _logdir->dynamic = properties[i].dynamic;
105 _logdir->domain = properties[i].domain;
106 _logdir->domainSize = properties[i].domainSize;
|
107 kumpf 1.9 _logdir->externallyVisible = properties[i].externallyVisible;
|
108 mike 1.2 }
|
109 konrad.r 1.17 else
110 #endif
111 if (String::equalNoCase(properties[i].propertyName, "logLevel"))
|
112 mike 1.2 {
|
113 david 1.6 _logLevel->propertyName = properties[i].propertyName;
114 _logLevel->defaultValue = properties[i].defaultValue;
115 _logLevel->currentValue = properties[i].defaultValue;
116 _logLevel->plannedValue = properties[i].defaultValue;
117 _logLevel->dynamic = properties[i].dynamic;
118 _logLevel->domain = properties[i].domain;
119 _logLevel->domainSize = properties[i].domainSize;
|
120 kumpf 1.9 _logLevel->externallyVisible = properties[i].externallyVisible;
|
121 david 1.7
122 Logger::setlogLevelMask(_logLevel->currentValue);
|
123 mike 1.2 }
124 }
125 }
126
|
127 kumpf 1.4 struct ConfigProperty* LogPropertyOwner::_lookupConfigProperty(
|
128 aruran.ms 1.21 const String& name) const
|
129 mike 1.2 {
|
130 konrad.r 1.17 #if !defined(PEGASUS_USE_SYSLOGS)
|
131 kumpf 1.8 if (String::equalNoCase(_logdir->propertyName, name))
|
132 mike 1.2 {
|
133 a.arora 1.12 return _logdir.get();
|
134 mike 1.2 }
|
135 konrad.r 1.17 else
136 #endif
137 if (String::equalNoCase(_logLevel->propertyName, name))
|
138 mike 1.2 {
|
139 a.arora 1.12 return _logLevel.get();
|
140 mike 1.2 }
141 else
142 {
143 throw UnrecognizedConfigProperty(name);
144 }
145 }
146
|
147 chip 1.15 /**
|
148 kumpf 1.4 Get information about the specified property.
|
149 mike 1.2 */
|
150 kumpf 1.4 void LogPropertyOwner::getPropertyInfo(
|
151 chip 1.15 const String& name,
|
152 vijay.eli 1.20 Array<String>& propertyInfo) const
|
153 mike 1.2 {
|
154 kumpf 1.4 propertyInfo.clear();
155
|
156 aruran.ms 1.21 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
157 kumpf 1.4
158 propertyInfo.append(configProperty->propertyName);
159 propertyInfo.append(configProperty->defaultValue);
160 propertyInfo.append(configProperty->currentValue);
161 propertyInfo.append(configProperty->plannedValue);
162 if (configProperty->dynamic)
|
163 kumpf 1.9 {
164 propertyInfo.append(STRING_TRUE);
165 }
166 else
167 {
168 propertyInfo.append(STRING_FALSE);
169 }
170 if (configProperty->externallyVisible)
|
171 mike 1.2 {
|
172 kumpf 1.4 propertyInfo.append(STRING_TRUE);
|
173 mike 1.2 }
174 else
175 {
|
176 kumpf 1.4 propertyInfo.append(STRING_FALSE);
|
177 mike 1.2 }
178 }
179
|
180 chip 1.15 /**
|
181 kumpf 1.4 Get default value of the specified property.
182 */
|
183 vijay.eli 1.20 String LogPropertyOwner::getDefaultValue(const String& name) const
|
184 kumpf 1.4 {
|
185 aruran.ms 1.21 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
186 vijay.eli 1.20
|
187 kumpf 1.4 return configProperty->defaultValue;
188 }
189
|
190 chip 1.15 /**
|
191 mike 1.2 Get current value of the specified property.
192 */
|
193 vijay.eli 1.20 String LogPropertyOwner::getCurrentValue(const String& name) const
|
194 mike 1.2 {
|
195 aruran.ms 1.21 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
196 vijay.eli 1.20
|
197 kumpf 1.4 return configProperty->currentValue;
|
198 mike 1.2 }
199
|
200 chip 1.15 /**
|
201 mike 1.2 Get planned value of the specified property.
202 */
|
203 vijay.eli 1.20 String LogPropertyOwner::getPlannedValue(const String& name) const
|
204 mike 1.2 {
|
205 aruran.ms 1.21 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
206 vijay.eli 1.20
|
207 kumpf 1.4 return configProperty->plannedValue;
|
208 mike 1.2 }
209
210
|
211 chip 1.15 /**
|
212 mike 1.2 Init current value of the specified property to the specified value.
213 */
214 void LogPropertyOwner::initCurrentValue(
|
215 chip 1.15 const String& name,
|
216 mike 1.2 const String& value)
217 {
|
218 david 1.6 if(String::equalNoCase(_logLevel->propertyName,name))
219 {
220 _logLevel->currentValue = value;
221 Logger::setlogLevelMask(_logLevel->currentValue);
222 }
223 else
224 {
225 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
226 configProperty->currentValue = value;
227 }
|
228 mike 1.2 }
229
230
|
231 chip 1.15 /**
|
232 mike 1.2 Init planned value of the specified property to the specified value.
233 */
234 void LogPropertyOwner::initPlannedValue(
|
235 chip 1.15 const String& name,
|
236 mike 1.2 const String& value)
237 {
|
238 kumpf 1.4 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
239 configProperty->plannedValue = value;
|
240 mike 1.2 }
241
|
242 chip 1.15 /**
|
243 mike 1.2 Update current value of the specified property to the specified value.
244 */
245 void LogPropertyOwner::updateCurrentValue(
|
246 chip 1.15 const String& name,
247 const String& value)
|
248 mike 1.2 {
249 //
250 // make sure the property is dynamic before updating the value.
251 //
252 if (!isDynamic(name))
253 {
|
254 chip 1.15 throw NonDynamicConfigProperty(name);
|
255 mike 1.2 }
256
257 //
|
258 chip 1.15 // Since the validations done in initCurrrentValue are sufficient and
259 // no additional validations required for update, we will call
|
260 mike 1.2 // initCurrrentValue.
261 //
262 initCurrentValue(name, value);
263 }
264
265
|
266 chip 1.15 /**
|
267 mike 1.2 Update planned value of the specified property to the specified value.
268 */
269 void LogPropertyOwner::updatePlannedValue(
|
270 chip 1.15 const String& name,
|
271 mike 1.2 const String& value)
272 {
273 //
|
274 chip 1.15 // Since the validations done in initPlannedValue are sufficient and
275 // no additional validations required for update, we will call
|
276 mike 1.2 // initPlannedValue.
277 //
278 initPlannedValue(name, value);
279 }
280
|
281 chip 1.15 /**
|
282 mike 1.2 Checks to see if the given value is valid or not.
283 */
284 Boolean LogPropertyOwner::isValid(const String& name, const String& value)
|
285 vijay.eli 1.20 const
|
286 mike 1.2 {
|
287 david 1.6 if (String::equalNoCase(_logLevel->propertyName, name))
288 {
|
289 chip 1.15 //
290 // Check if the logLevel is valid
291 //
292 if (!Logger::isValidlogLevel(value))
293 {
294 throw InvalidPropertyValue(name, value);
|
295 david 1.6 }
296 }
297
|
298 chip 1.15 return(true);
|
299 mike 1.2 }
300
|
301 chip 1.15 /**
|
302 mike 1.2 Checks to see if the specified property is dynamic or not.
303 */
|
304 vijay.eli 1.20 Boolean LogPropertyOwner::isDynamic(const String& name) const
|
305 mike 1.2 {
|
306 aruran.ms 1.21 struct ConfigProperty* configProperty = _lookupConfigProperty(name);
|
307 vijay.eli 1.20
|
308 konrad.r 1.14 return (configProperty->dynamic == IS_DYNAMIC);
|
309 mike 1.2 }
310
311
312 PEGASUS_NAMESPACE_END
|