1 karl 1.34 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.24 // 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.21 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.24 // 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.27 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.34 // 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.34 //
|
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 sage 1.4 #include <Pegasus/Common/Config.h>
|
35 mike 1.2 #include <Pegasus/Common/Tracer.h>
|
36 kumpf 1.3 #include <Pegasus/Common/Thread.h>
37 #include <Pegasus/Common/System.h>
|
38 mike 1.2
39 PEGASUS_USING_STD;
40
41 PEGASUS_NAMESPACE_BEGIN
42
43 // Set the trace levels
44 // These levels will be compared against a trace level mask to determine
|
45 chip 1.20 // if a specific trace level is enabled
|
46 mike 1.2
47 const Uint32 Tracer::LEVEL1 = (1 << 0);
48 const Uint32 Tracer::LEVEL2 = (1 << 1);
49 const Uint32 Tracer::LEVEL3 = (1 << 2);
50 const Uint32 Tracer::LEVEL4 = (1 << 3);
51
52 // Set the return codes
53 const Boolean Tracer::_SUCCESS = 1;
54 const Boolean Tracer::_FAILURE = 0;
55
56 // Set the Enter and Exit messages
|
57 kumpf 1.13 const char Tracer::_METHOD_ENTER_MSG[] = "Entering method";
58 const char Tracer::_METHOD_EXIT_MSG[] = "Exiting method";
|
59 mike 1.2
60 // Set Log messages
|
61 kumpf 1.40 const char Tracer::_LOG_MSG[] =
62 "LEVEL1 may only be used with trace macros "
63 "PEG_METHOD_ENTER/PEG_METHOD_EXIT.";
|
64 mike 1.2
65 // Initialize singleton instance of Tracer
66 Tracer* Tracer::_tracerInstance = 0;
|
67 chip 1.20
|
68 mike 1.2 // Set component separator
69 const char Tracer::_COMPONENT_SEPARATOR = ',';
70
71 // Set the number of defined components
|
72 chip 1.20 const Uint32 Tracer::_NUM_COMPONENTS =
|
73 mike 1.2 sizeof(TRACE_COMPONENT_LIST)/sizeof(TRACE_COMPONENT_LIST[0]);
74
75 // Set the line maximum
76 const Uint32 Tracer::_STRLEN_MAX_UNSIGNED_INT = 21;
77
|
78 kumpf 1.3 // Set the max PID and Thread ID Length
|
79 mike 1.39 const Uint32 Tracer::_STRLEN_MAX_PID_TID = 21;
|
80 kumpf 1.3
|
81 r.kieninger 1.30 // Initialize public indicator of trace state
|
82 david.dillard 1.32 Boolean Tracer::_traceOn = false;
|
83 r.kieninger 1.30
|
84 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
85 // Tracer constructor
86 // Constructor is private to preclude construction of Tracer objects
87 // Single Instance of Tracer is maintained for each process.
88 ////////////////////////////////////////////////////////////////////////////////
89 Tracer::Tracer()
|
90 aruran.ms 1.33 : _traceComponentMask(new Boolean[_NUM_COMPONENTS]),
91 _traceLevelMask(0),
92 _traceHandler(new TraceFileHandler())
|
93 mike 1.2 {
94 // Initialize ComponentMask array to false
|
95 chip 1.20 for (Uint32 index=0;index < _NUM_COMPONENTS;
|
96 david.dillard 1.32 (_traceComponentMask.get())[index++]=false);
|
97 mike 1.2 }
|
98 chip 1.20
|
99 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
100 //Tracer destructor
101 ////////////////////////////////////////////////////////////////////////////////
102 Tracer::~Tracer()
103 {
104 delete _tracerInstance;
105 }
106
107
108 ////////////////////////////////////////////////////////////////////////////////
109 //Traces the given message
110 ////////////////////////////////////////////////////////////////////////////////
111 void Tracer::_trace(
112 const Uint32 traceComponent,
113 const char* fmt,
114 va_list argList)
115 {
|
116 marek 1.42 _trace(traceComponent, "", fmt, argList);
|
117 mike 1.2 }
118
119 ////////////////////////////////////////////////////////////////////////////////
120 //Traces the given message - Overloaded for including FileName and Line number
121 ////////////////////////////////////////////////////////////////////////////////
122 void Tracer::_trace(
123 const char* fileName,
124 const Uint32 lineNum,
125 const Uint32 traceComponent,
126 const char* fmt,
127 va_list argList)
128 {
129 char* message;
|
130 marek 1.42 //
131 // Allocate memory for the message string
132 // Needs to be updated if additional info is added
133 //
134 message = new char[strlen(fileName) +
135 _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8];
136 sprintf(
137 message,
138 "[%d:%s:%s:%u]: ",
139 System::getPID(),
140 Threads::id().buffer,
141 fileName,
142 lineNum);
|
143 mike 1.2
|
144 marek 1.42 _trace(traceComponent, message, fmt, argList);
145 delete [] message;
|
146 mike 1.2 }
147
148 ////////////////////////////////////////////////////////////////////////////////
|
149 marek 1.42 //Traces the given string - Overloaded to include the fileName and line number
150 //of trace origin.
|
151 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
|
152 marek 1.42 void Tracer::_traceCString(
|
153 mike 1.2 const char* fileName,
154 const Uint32 lineNum,
155 const Uint32 traceComponent,
|
156 marek 1.42 const char* cstring)
|
157 mike 1.2 {
|
158 marek 1.42 char* message;
|
159 mike 1.2
|
160 marek 1.42 //
161 // Allocate memory for the message string
162 // Needs to be updated if additional info is added
163 //
164 message = new char[strlen(fileName) +
165 _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8];
166 sprintf(
167 message,
168 "[%d:%s:%s:%u]: ",
169 System::getPID(),
170 Threads::id().buffer,
171 fileName,
172 lineNum);
|
173 kumpf 1.5
|
174 marek 1.42 _traceCString(traceComponent, message, cstring);
175 delete [] message;
|
176 kumpf 1.5 }
177
178 ////////////////////////////////////////////////////////////////////////////////
179 //Traces the message in the given CIMException object.
180 ////////////////////////////////////////////////////////////////////////////////
181 void Tracer::_traceCIMException(
182 const Uint32 traceComponent,
|
183 kumpf 1.40 const CIMException& cimException)
|
184 marek 1.42 {
|
185 kumpf 1.43 // get the CIMException trace message string
186 CString traceMsg =
187 TraceableCIMException(cimException).getTraceDescription().getCString();
188 // trace the string
189 _traceCString(traceComponent, "", (const char*) traceMsg);
|
190 mike 1.2 }
191
192 ////////////////////////////////////////////////////////////////////////////////
|
193 marek 1.42 //Traces method entry and exit
|
194 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
|
195 marek 1.42 void Tracer::_traceMethod(
|
196 mike 1.2 const char* fileName,
197 const Uint32 lineNum,
198 const Uint32 traceComponent,
|
199 marek 1.42 const char* methodEntryExit,
200 const char* method)
|
201 mike 1.2 {
202 char* message;
203
|
204 marek 1.42 //
205 // Allocate memory for the message string
206 // Needs to be updated if additional info is added
207 //
208 // assume Method entry/exit string 15 characters long
209 // +1 space character
210 message = new char[ strlen(fileName) +
211 _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8
212 + 16];
213
214 sprintf(
215 message,
216 "[%d:%s:%s:%u]: %s ",
217 System::getPID(),
218 Threads::id().buffer,
219 fileName,
220 lineNum,
221 methodEntryExit);
222
223 _traceCString(traceComponent, message, method);
|
224 carson.hovey 1.37
|
225 marek 1.42 delete [] message;
|
226 mike 1.2 }
227
228
229 ////////////////////////////////////////////////////////////////////////////////
230 //Checks if trace is enabled for the given component and level
231 ////////////////////////////////////////////////////////////////////////////////
|
232 kumpf 1.40 Boolean Tracer::_isTraceEnabled(
233 const Uint32 traceComponent,
|
234 mike 1.2 const Uint32 traceLevel)
235 {
236 Tracer* instance = _getInstance();
237 if (traceComponent >= _NUM_COMPONENTS)
238 {
|
239 david.dillard 1.32 return false;
|
240 mike 1.2 }
|
241 a.arora 1.22 return (((instance->_traceComponentMask.get())[traceComponent]) &&
|
242 kumpf 1.40 (traceLevel & instance->_traceLevelMask));
|
243 mike 1.2 }
244
245 ////////////////////////////////////////////////////////////////////////////////
|
246 marek 1.42 //Called by all trace interfaces with variable arguments
247 //to log message to trace file
|
248 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
249 void Tracer::_trace(
250 const Uint32 traceComponent,
251 const char* message,
252 const char* fmt,
253 va_list argList)
254 {
255 char* msgHeader;
256
257 // Get the current system time and prepend to message
258 String currentTime = System::getCurrentASCIITime();
|
259 kumpf 1.17 CString timeStamp = currentTime.getCString();
|
260 mike 1.2
|
261 kumpf 1.3 //
|
262 chip 1.20 // Allocate messageHeader.
|
263 kumpf 1.3 // Needs to be updated if additional info is added
264 //
|
265 mday 1.19
|
266 mike 1.2 // Construct the message header
|
267 chip 1.20 // The message header is in the following format
|
268 mike 1.2 // timestamp: <component name> [file name:line number]
|
269 joyce.j 1.26 if (*message != '\0')
|
270 mike 1.2 {
|
271 kumpf 1.40 // << Wed Jul 16 10:58:40 2003 mdd >> _STRLEN_MAX_PID_TID is not used
272 // in this format string
273 msgHeader = new char [strlen(message) +
274 strlen(TRACE_COMPONENT_LIST[traceComponent]) +
275 strlen(timeStamp) + _STRLEN_MAX_PID_TID + 5];
276
277 sprintf(msgHeader, "%s: %s %s", (const char*)timeStamp,
278 TRACE_COMPONENT_LIST[traceComponent], message);
|
279 mike 1.2 }
280 else
281 {
|
282 kumpf 1.3 //
|
283 marek 1.42 // Since the message is blank, form a string using the pid and tid
|
284 kumpf 1.3 //
|
285 kumpf 1.40 char* tmpBuffer;
|
286 kumpf 1.3
287 //
|
288 chip 1.20 // Allocate messageHeader.
|
289 kumpf 1.3 // Needs to be updated if additional info is added
290 //
|
291 mike 1.39 tmpBuffer = new char[2 * _STRLEN_MAX_PID_TID + 6];
|
292 kumpf 1.40 sprintf(tmpBuffer, "[%u:%s]: ",
293 System::getPID(), Threads::id().buffer);
294 msgHeader = new char[strlen(timeStamp) +
295 strlen(TRACE_COMPONENT_LIST[traceComponent]) +
296 strlen(tmpBuffer) + 1 + 5];
297
298 sprintf(msgHeader, "%s: %s %s ", (const char*)timeStamp,
299 TRACE_COMPONENT_LIST[traceComponent], tmpBuffer);
300 delete [] tmpBuffer;
|
301 mike 1.2 }
302
303 // Call trace file handler to write message
304 _getInstance()->_traceHandler->handleMessage(msgHeader,fmt,argList);
|
305 chip 1.20
306 delete [] msgHeader;
|
307 mike 1.2 }
308
309 ////////////////////////////////////////////////////////////////////////////////
|
310 marek 1.42 //Called by all trace interfaces using a character string without format string
311 //to log message to trace file
312 ////////////////////////////////////////////////////////////////////////////////
313 void Tracer::_traceCString(
314 const Uint32 traceComponent,
315 const char* message,
316 const char* cstring)
317 {
318 char* completeMessage;
319
320 // Get the current system time and prepend to message
321 String currentTime = System::getCurrentASCIITime();
322 CString timeStamp = currentTime.getCString();
323 //
324 // Allocate completeMessage.
325 // Needs to be updated if additional info is added
326 //
327
328 // Construct the message header
329 // The message header is in the following format
330 // timestamp: <component name> [file name:line number]
331 marek 1.42 if (*message != '\0')
332 {
333 // << Wed Jul 16 10:58:40 2003 mdd >> _STRLEN_MAX_PID_TID is not used
334 // in this format string
335 completeMessage = new char [strlen(message) +
336 strlen(TRACE_COMPONENT_LIST[traceComponent]) +
337 strlen(timeStamp) + _STRLEN_MAX_PID_TID + 5 +
338 strlen(cstring) ];
339
340 sprintf(completeMessage, "%s: %s %s%s", (const char*)timeStamp,
341 TRACE_COMPONENT_LIST[traceComponent], message, cstring);
342 }
343 else
344 {
345 //
346 // Since the message is blank, form a string using the pid and tid
347 //
348 char* tmpBuffer;
349
350 //
351 // Allocate messageHeader.
352 marek 1.42 // Needs to be updated if additional info is added
353 //
354 tmpBuffer = new char[2 * _STRLEN_MAX_PID_TID + 6];
355 sprintf(tmpBuffer, "[%u:%s]: ",
356 System::getPID(), Threads::id().buffer);
357
358 completeMessage = new char[strlen(timeStamp) +
359 strlen(TRACE_COMPONENT_LIST[traceComponent]) +
360 strlen(tmpBuffer) + 1 + 5 +
361 strlen(cstring)];
362
363 sprintf(completeMessage, "%s: %s %s %s", (const char*)timeStamp,
364 TRACE_COMPONENT_LIST[traceComponent], tmpBuffer, cstring);
365 delete [] tmpBuffer;
366 }
367
368 // Call trace file handler to write message
369 _getInstance()->_traceHandler->handleMessage(completeMessage);
370
371 delete [] completeMessage;
372 }
373 marek 1.42
374
375 ////////////////////////////////////////////////////////////////////////////////
|
376 mike 1.2 //Validate the trace file
377 ////////////////////////////////////////////////////////////////////////////////
|
378 kumpf 1.10 Boolean Tracer::isValidFileName(const char* filePath)
|
379 mike 1.2 {
|
380 kumpf 1.23 String moduleName = _getInstance()->_moduleName;
381 if (moduleName == String::EMPTY)
382 {
|
383 kumpf 1.40 return _getInstance()->_traceHandler->isValidFilePath(filePath);
|
384 kumpf 1.23 }
385 else
386 {
387 String extendedFilePath = String(filePath) + "." + moduleName;
|
388 kumpf 1.40 return _getInstance()->_traceHandler->isValidFilePath(
389 extendedFilePath.getCString());
|
390 kumpf 1.23 }
|
391 mike 1.2 }
392
393 ////////////////////////////////////////////////////////////////////////////////
394 //Validate the trace components
395 ////////////////////////////////////////////////////////////////////////////////
|
396 kumpf 1.23 Boolean Tracer::isValidComponents(const String& traceComponents)
|
397 kumpf 1.10 {
398 String invalidComponents;
399 return isValidComponents(traceComponents, invalidComponents);
400 }
401
402 Boolean Tracer::isValidComponents(
|
403 kumpf 1.40 const String& traceComponents,
404 String& invalidComponents)
|
405 mike 1.2 {
406 // Validate the trace components and modify the traceComponents argument
407 // to reflect the invalid components
408
409 Uint32 position=0;
410 Uint32 index=0;
411 String componentName = String::EMPTY;
412 String componentStr = String::EMPTY;
413 Boolean validComponent=false;
414 Boolean retCode=true;
415
416 componentStr = traceComponents;
417 invalidComponents = String::EMPTY;
418
419 if (componentStr != String::EMPTY)
420 {
421 // Check if ALL is specified
422 if (String::equalNoCase(componentStr,"ALL"))
423 {
424 return _SUCCESS;
425 }
426 mike 1.2
427 // Append _COMPONENT_SEPARATOR to the end of the traceComponents
|
428 kumpf 1.16 componentStr.append(_COMPONENT_SEPARATOR);
|
429 mike 1.2
430 while (componentStr != String::EMPTY)
431 {
|
432 david.dillard 1.32 //
|
433 mike 1.2 // Get the Component name from traceComponents.
434 // Components are separated by _COMPONENT_SEPARATOR
|
435 david.dillard 1.32 //
|
436 mike 1.2 position = componentStr.find(_COMPONENT_SEPARATOR);
437 componentName = componentStr.subString(0,(position));
438
439 // Lookup the index for Component name in TRACE_COMPONENT_LIST
440 index = 0;
441 validComponent = false;
442
443 while (index < _NUM_COMPONENTS)
444 {
|
445 chip 1.20 if (String::equalNoCase(
|
446 david.dillard 1.32 componentName, TRACE_COMPONENT_LIST[index]))
|
447 mike 1.2 {
448 // Found component, break from the loop
|
449 david.dillard 1.32 validComponent = true;
|
450 mike 1.2 break;
451 }
452 else
453 {
454 index++;
455 }
456 }
457
458 // Remove the searched componentname from the traceComponents
459 componentStr.remove(0,position+1);
460
|
461 kumpf 1.40 if (!validComponent)
|
462 david.dillard 1.32 {
463 invalidComponents.append(componentName);
464 invalidComponents.append(_COMPONENT_SEPARATOR);
|
465 mike 1.2 }
466 }
467 }
468 else
469 {
|
470 david.dillard 1.32 // trace components is empty, it is a valid value so return true
471 return _SUCCESS;
|
472 mike 1.2 }
|
473 kumpf 1.40
474 if (invalidComponents != String::EMPTY)
|
475 mike 1.2 {
|
476 david.dillard 1.32 retCode = false;
477 //
478 // Remove the extra ',' at the end
479 //
480 invalidComponents.remove(
481 invalidComponents.reverseFind(_COMPONENT_SEPARATOR));
|
482 mike 1.2 }
483 return retCode;
484 }
|
485 chip 1.20
|
486 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
|
487 kumpf 1.23 //Set the name of the module being traced
488 ////////////////////////////////////////////////////////////////////////////////
489 void Tracer::setModuleName(const String& moduleName)
490 {
491 _getInstance()->_moduleName = moduleName;
492 }
493
494 ////////////////////////////////////////////////////////////////////////////////
|
495 mike 1.2 //Returns the Singleton instance of the Tracer
496 ////////////////////////////////////////////////////////////////////////////////
497 Tracer* Tracer::_getInstance()
498 {
499 if (_tracerInstance == 0)
500 {
501 _tracerInstance = new Tracer();
502 }
503 return _tracerInstance;
504 }
505
|
506 chip 1.20 // PEGASUS_REMOVE_TRACE defines the compile time inclusion of the Trace
|
507 karl 1.35 // interfaces. This section defines the trace functions IF the remove
508 // trace flag is NOT set. If it is set, they are defined as empty functions
509 // in the header file.
|
510 mike 1.2
511 #ifndef PEGASUS_REMOVE_TRACE
512
513 ////////////////////////////////////////////////////////////////////////////////
514 //Set the trace file
515 ////////////////////////////////////////////////////////////////////////////////
516 Uint32 Tracer::setTraceFile(const char* traceFile)
517 {
|
518 kumpf 1.25 if (*traceFile == 0)
519 {
520 return 1;
521 }
522
|
523 kumpf 1.23 String moduleName = _getInstance()->_moduleName;
524 if (moduleName == String::EMPTY)
525 {
|
526 kumpf 1.40 return _getInstance()->_traceHandler->setFileName(traceFile);
|
527 kumpf 1.23 }
528 else
529 {
530 String extendedTraceFile = String(traceFile) + "." + moduleName;
|
531 kumpf 1.40 return _getInstance()->_traceHandler->setFileName(
532 extendedTraceFile.getCString());
|
533 kumpf 1.23 }
|
534 chip 1.20 }
|
535 mike 1.2
536 ////////////////////////////////////////////////////////////////////////////////
537 //Set the trace level
538 ////////////////////////////////////////////////////////////////////////////////
539 Uint32 Tracer::setTraceLevel(const Uint32 traceLevel)
540 {
541 Uint32 retCode = 0;
542
543 switch (traceLevel)
544 {
|
545 david.dillard 1.32 case LEVEL1:
|
546 mike 1.2 _getInstance()->_traceLevelMask = 0x01;
|
547 david.dillard 1.32 break;
|
548 chip 1.20
|
549 mike 1.2 case LEVEL2:
550 _getInstance()->_traceLevelMask = 0x03;
|
551 david.dillard 1.32 break;
|
552 mike 1.2
553 case LEVEL3:
554 _getInstance()->_traceLevelMask = 0x07;
|
555 david.dillard 1.32 break;
|
556 mike 1.2
557 case LEVEL4:
558 _getInstance()->_traceLevelMask = 0x0F;
|
559 david.dillard 1.32 break;
|
560 mike 1.2
561 default:
562 _getInstance()->_traceLevelMask = 0;
563 retCode = 1;
564 }
565 return retCode;
566 }
567
568 ////////////////////////////////////////////////////////////////////////////////
|
569 chip 1.20 // Set components to be traced.
|
570 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
|
571 kumpf 1.23 void Tracer::setTraceComponents(const String& traceComponents)
|
572 mike 1.2 {
573 Uint32 position = 0;
574 Uint32 index = 0;
575 String componentName = String::EMPTY;
576 String componentStr = traceComponents;
577 String invalidComponents = String::EMPTY;
|
578 chip 1.20
|
579 mike 1.2 if (componentStr != String::EMPTY)
580 {
581 // Check if ALL is specified
582 if (String::equalNoCase(componentStr,"ALL"))
583 {
|
584 kumpf 1.40 for (index = 0; index < _NUM_COMPONENTS; index++)
585 {
586 (_getInstance()->_traceComponentMask.get())[index] = true;
587 }
|
588 david.dillard 1.32 _traceOn = true;
|
589 kumpf 1.40 return;
|
590 mike 1.2 }
591
|
592 kumpf 1.40 // initialize ComponentMask array to False
593 for (index = 0; index < _NUM_COMPONENTS; index++)
594 {
595 (_getInstance()->_traceComponentMask.get())[index] = false;
596 }
|
597 david.dillard 1.32 _traceOn = false;
|
598 mike 1.2
|
599 r.kieninger 1.30 // Append _COMPONENT_SEPARATOR to the end of the traceComponents
|
600 kumpf 1.16 componentStr.append(_COMPONENT_SEPARATOR);
|
601 mike 1.2
602 while (componentStr != String::EMPTY)
603 {
|
604 chip 1.20 // Get the Component name from traceComponents.
|
605 r.kieninger 1.30 // Components are separated by _COMPONENT_SEPARATOR
|
606 mike 1.2 position = componentStr.find(_COMPONENT_SEPARATOR);
|
607 r.kieninger 1.30 componentName = componentStr.subString(0,(position));
|
608 mike 1.2
|
609 r.kieninger 1.30 // Lookup the index for Component name in TRACE_COMPONENT_LIST
|
610 mike 1.2 index = 0;
|
611 r.kieninger 1.30 while (index < _NUM_COMPONENTS)
612 {
613 if (String::equalNoCase(
614 componentName,TRACE_COMPONENT_LIST[index]))
615 {
|
616 kumpf 1.40 (_getInstance()->_traceComponentMask.get())[index] = true;
|
617 david.dillard 1.32 _traceOn = true;
|
618 mike 1.2
619 // Found component, break from the loop
620 break;
|
621 r.kieninger 1.30 }
622 else
623 {
624 index++;
|
625 mike 1.2 }
|
626 chip 1.20 }
|
627 mike 1.2
628 // Remove the searched componentname from the traceComponents
629 componentStr.remove(0,position+1);
630 }
631 }
632 else
633 {
634 // initialise ComponentMask array to False
|
635 kumpf 1.40 for (Uint32 index = 0;index < _NUM_COMPONENTS; index++)
636 {
637 (_getInstance()->_traceComponentMask.get())[index] = false;
638 }
|
639 r.kieninger 1.31 _traceOn = 0;
|
640 mike 1.2 }
641 return ;
642 }
643
|
644 kumpf 1.40 void Tracer::traceEnter(
645 TracerToken& token,
|
646 karl 1.35 const char* file,
647 size_t line,
|
648 kumpf 1.40 Uint32 traceComponent,
|
649 karl 1.35 const char* method)
650 {
|
651 marek 1.42 token.component = traceComponent;
652 token.method = method;
653
654 if (_isTraceEnabled(traceComponent, LEVEL1))
|
655 karl 1.35 {
|
656 marek 1.42 _traceMethod(
657 file, (Uint32)line, traceComponent,
|
658 a.dunfey 1.41 _METHOD_ENTER_MSG, method);
|
659 karl 1.35 }
660 }
661
662 void Tracer::traceExit(
663 TracerToken& token,
664 const char* file,
665 size_t line)
666 {
|
667 marek 1.42 if (_isTraceEnabled(token.component, LEVEL1))
668 _traceMethod(
669 file, (Uint32)line, token.component,
|
670 kumpf 1.40 _METHOD_EXIT_MSG, token.method);
|
671 karl 1.35 }
672
673 void Tracer::trace(
674 const Uint32 traceComponent,
675 const Uint32 traceLevel,
676 const char *fmt,
677 ...)
678 {
|
679 marek 1.42 PEGASUS_ASSERT(traceLevel != LEVEL1);
680 if (_isTraceEnabled(traceComponent, traceLevel))
|
681 karl 1.35 {
|
682 kumpf 1.40 va_list argList;
683 va_start(argList,fmt);
|
684 marek 1.42 _trace(traceComponent,fmt,argList);
|
685 kumpf 1.40 va_end(argList);
|
686 karl 1.35 }
687 }
688
689 void Tracer::trace(
690 const char* fileName,
691 const Uint32 lineNum,
692 const Uint32 traceComponent,
693 const Uint32 traceLevel,
694 const char* fmt,
695 ...)
696 {
|
697 marek 1.42 PEGASUS_ASSERT(traceLevel != LEVEL1);
698 if (_isTraceEnabled(traceComponent, traceLevel))
|
699 karl 1.35 {
|
700 kumpf 1.40 va_list argList;
|
701 karl 1.35
|
702 kumpf 1.40 va_start(argList,fmt);
|
703 marek 1.42 _trace(fileName,lineNum,traceComponent,fmt,argList);
|
704 kumpf 1.40 va_end(argList);
|
705 karl 1.35 }
706 }
707
|
708 marek 1.42 void Tracer::traceString(
|
709 kumpf 1.40 const char* fileName,
710 const Uint32 lineNum,
711 const Uint32 traceComponent,
712 const Uint32 traceLevel,
|
713 marek 1.42 const String& string)
|
714 karl 1.35 {
|
715 marek 1.42 PEGASUS_ASSERT(traceLevel != LEVEL1);
716 if (_isTraceEnabled(traceComponent, traceLevel))
|
717 karl 1.35 {
|
718 marek 1.42 _traceCString(
|
719 kumpf 1.43 fileName,
720 lineNum,
721 traceComponent,
722 (const char*) string.getCString());
|
723 karl 1.35 }
724 }
725
|
726 marek 1.42 void Tracer::traceCString(
727 const char* fileName,
728 const Uint32 lineNum,
|
729 kumpf 1.40 const Uint32 traceComponent,
730 const Uint32 traceLevel,
|
731 marek 1.42 const char* cstring)
|
732 karl 1.35 {
|
733 marek 1.42 PEGASUS_ASSERT(traceLevel != LEVEL1);
734 if (_isTraceEnabled(traceComponent, traceLevel))
|
735 karl 1.35 {
|
736 marek 1.42 _traceCString(
737 fileName, lineNum, traceComponent, cstring);
|
738 karl 1.35 }
739 }
740
|
741 marek 1.42 void Tracer::traceCIMException(
|
742 kumpf 1.40 const Uint32 traceComponent,
|
743 marek 1.42 const Uint32 traceLevel,
744 const CIMException& cimException)
|
745 karl 1.35 {
|
746 marek 1.42 PEGASUS_ASSERT(traceLevel != LEVEL1);
747 if (_isTraceEnabled(traceComponent, traceLevel))
748 {
749 _traceCIMException(traceComponent, cimException);
750 }
|
751 karl 1.35 }
752
753 #endif /* !PEGASUS_REMOVE_TRACE */
|
754 mike 1.2
755 PEGASUS_NAMESPACE_END
|