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