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