1 karl 1.21 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.21 // 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 // IBM Corp.; EMC Corporation, The Open Group.
|
7 mike 1.2 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
|
14 karl 1.21 //
|
15 mike 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
24 //==============================================================================
25 //
26 // Author: Sushma Fernandes, Hewlett-Packard Company (sushma_fernandes@hp.com)
27 //
|
28 kumpf 1.5 // Modified By: Jenny Yu, Hewlett-Packard Company (jenny_yu@hp.com)
|
29 a.arora 1.22 // Amit K Arora, IBM (amita@in.ibm.com) for PEP#101
|
30 kumpf 1.23 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
31 mike 1.2 //
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/IPC.h>
38 #include <Pegasus/Common/System.h>
|
39 mike 1.2
40 PEGASUS_USING_STD;
41
42 PEGASUS_NAMESPACE_BEGIN
43
44 // Set the trace levels
45 // These levels will be compared against a trace level mask to determine
|
46 chip 1.20 // if a specific trace level is enabled
|
47 mike 1.2
48 const Uint32 Tracer::LEVEL1 = (1 << 0);
49 const Uint32 Tracer::LEVEL2 = (1 << 1);
50 const Uint32 Tracer::LEVEL3 = (1 << 2);
51 const Uint32 Tracer::LEVEL4 = (1 << 3);
52
53 // Set the return codes
54 const Boolean Tracer::_SUCCESS = 1;
55 const Boolean Tracer::_FAILURE = 0;
56
57 // Set the Enter and Exit messages
|
58 kumpf 1.13 const char Tracer::_METHOD_ENTER_MSG[] = "Entering method";
59 const char Tracer::_METHOD_EXIT_MSG[] = "Exiting method";
|
60 mike 1.2
61 // Set Log messages
|
62 kumpf 1.13 const char Tracer::_LOG_MSG[] = "LEVEL1 may only be used with trace macros PEG_METHOD_ENTER/PEG_METHOD_EXIT.";
|
63 mike 1.2
64 // Initialize singleton instance of Tracer
65 Tracer* Tracer::_tracerInstance = 0;
|
66 chip 1.20
|
67 mike 1.2 // Set component separator
68 const char Tracer::_COMPONENT_SEPARATOR = ',';
69
70 // Set the number of defined components
|
71 chip 1.20 const Uint32 Tracer::_NUM_COMPONENTS =
|
72 mike 1.2 sizeof(TRACE_COMPONENT_LIST)/sizeof(TRACE_COMPONENT_LIST[0]);
73
74 // Set the line maximum
75 const Uint32 Tracer::_STRLEN_MAX_UNSIGNED_INT = 21;
76
|
77 kumpf 1.3 // Set the max PID and Thread ID Length
78 const Uint32 Tracer::_STRLEN_MAX_PID_TID = 20;
79
|
80 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
81 // Tracer constructor
82 // Constructor is private to preclude construction of Tracer objects
83 // Single Instance of Tracer is maintained for each process.
84 ////////////////////////////////////////////////////////////////////////////////
85 Tracer::Tracer()
86 {
87 // Initialize Trace File Handler
|
88 a.arora 1.22 _traceHandler.reset(new TraceFileHandler());
|
89 mike 1.2 _traceLevelMask=0;
|
90 a.arora 1.22 _traceComponentMask.reset(new Boolean[_NUM_COMPONENTS]);
|
91 mike 1.2
92 // Initialize ComponentMask array to false
|
93 chip 1.20 for (Uint32 index=0;index < _NUM_COMPONENTS;
|
94 a.arora 1.22 (_traceComponentMask.get())[index++]=false);
|
95 mike 1.2 }
|
96 chip 1.20
|
97 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
98 //Tracer destructor
99 ////////////////////////////////////////////////////////////////////////////////
100 Tracer::~Tracer()
101 {
102 delete _tracerInstance;
103 }
104
105
106 ////////////////////////////////////////////////////////////////////////////////
107 //Traces the given message
108 ////////////////////////////////////////////////////////////////////////////////
109 void Tracer::_trace(
110 const Uint32 traceComponent,
111 const Uint32 traceLevel,
112 const char* fmt,
113 va_list argList)
114 {
115 if ( traceLevel == LEVEL1 )
116 {
|
117 kumpf 1.14 trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );
|
118 mike 1.2 }
119 else
120 {
121 if (_isTraceEnabled(traceComponent,traceLevel))
122 {
|
123 chip 1.20 _trace(traceComponent,"",fmt,argList);
|
124 mike 1.2 }
125 }
126 }
127
128 ////////////////////////////////////////////////////////////////////////////////
129 //Traces the given message - Overloaded for including FileName and Line number
130 ////////////////////////////////////////////////////////////////////////////////
131 void Tracer::_trace(
132 const char* fileName,
133 const Uint32 lineNum,
134 const Uint32 traceComponent,
135 const Uint32 traceLevel,
136 const char* fmt,
137 va_list argList)
138 {
139 char* message;
140
141 if ( traceLevel == LEVEL1 )
142 {
|
143 kumpf 1.14 trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );
|
144 mike 1.2 }
145 else
146 {
147 if (_isTraceEnabled(traceComponent,traceLevel))
148 {
|
149 kumpf 1.3 //
150 // Allocate memory for the message string
151 // Needs to be updated if additional info is added
152 //
|
153 chip 1.20 message = new char[ strlen(fileName) +
|
154 mday 1.19 _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ];
|
155 kumpf 1.3 sprintf(
156 message,
|
157 kumpf 1.9 "[%d:%u:%s:%u]: ",
|
158 kumpf 1.3 System::getPID(),
|
159 kumpf 1.9 Uint32(pegasus_thread_self()),
|
160 kumpf 1.3 fileName,
161 lineNum);
|
162 mike 1.2
|
163 chip 1.20 _trace(traceComponent,message,fmt,argList);
|
164 mike 1.2 delete []message;
165 }
166 }
167 }
168
169 ////////////////////////////////////////////////////////////////////////////////
170 //Traces the given buffer
171 ////////////////////////////////////////////////////////////////////////////////
172 void Tracer::_traceBuffer(
173 const Uint32 traceComponent,
174 const Uint32 traceLevel,
175 const char* data,
176 const Uint32 size)
177 {
178 if ( traceLevel == LEVEL1 )
179 {
|
180 kumpf 1.14 trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );
|
181 mike 1.2 }
182 else
183 {
184 if (_isTraceEnabled(traceComponent,traceLevel))
185 {
186 char* tmpBuf = new char[size+1];
187
188 strncpy( tmpBuf, data, size );
189 tmpBuf[size] = '\0';
190 trace(traceComponent,traceLevel,"%s",tmpBuf);
191
192 delete []tmpBuf;
193 }
194 }
195 }
196 ////////////////////////////////////////////////////////////////////////////////
197 //Traces the given buffer - Overloaded for including FileName and Line number
198 ////////////////////////////////////////////////////////////////////////////////
199 void Tracer::_traceBuffer(
200 const char* fileName,
201 const Uint32 lineNum,
202 mike 1.2 const Uint32 traceComponent,
203 const Uint32 traceLevel,
204 const char* data,
205 const Uint32 size)
206 {
207 if ( traceLevel == LEVEL1 )
208 {
|
209 kumpf 1.14 trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );
|
210 mike 1.2 }
211 else
212 {
213 if ( _isTraceEnabled( traceComponent, traceLevel ) )
214 {
215 char* tmpBuf = new char[size+1];
216
217 strncpy( tmpBuf, data, size );
218 tmpBuf[size] = '\0';
219 trace(fileName,lineNum,traceComponent,traceLevel,"%s",tmpBuf);
220
221 delete []tmpBuf;
|
222 kumpf 1.5 }
223 }
224 }
225
226 ////////////////////////////////////////////////////////////////////////////////
227 //Traces the given string
228 ////////////////////////////////////////////////////////////////////////////////
229 void Tracer::_traceString(
230 const Uint32 traceComponent,
231 const Uint32 traceLevel,
232 const String& traceString)
233 {
234 if ( traceLevel == LEVEL1 )
235 {
|
236 kumpf 1.14 trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );
|
237 kumpf 1.5 }
238 else
239 {
240 if (_isTraceEnabled(traceComponent,traceLevel))
241 {
|
242 kumpf 1.18 trace(traceComponent,traceLevel,"%s",
243 (const char *)traceString.getCString());
|
244 kumpf 1.5 }
245 }
246 }
247
248 ////////////////////////////////////////////////////////////////////////////////
249 //Traces the given string - Overloaded to include the fileName and line number
250 //of trace origin.
251 ////////////////////////////////////////////////////////////////////////////////
252 void Tracer::_traceString(
253 const char* fileName,
254 const Uint32 lineNum,
255 const Uint32 traceComponent,
256 const Uint32 traceLevel,
257 const String& traceString)
258 {
259 if ( traceLevel == LEVEL1 )
260 {
|
261 kumpf 1.14 trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );
|
262 kumpf 1.5 }
263 else
264 {
265 if ( _isTraceEnabled( traceComponent, traceLevel ) )
266 {
|
267 kumpf 1.18 trace(fileName,lineNum,traceComponent,traceLevel,"%s",
268 (const char *)traceString.getCString());
|
269 kumpf 1.5 }
270 }
271 }
272
273 ////////////////////////////////////////////////////////////////////////////////
274 //Traces the message in the given CIMException object.
275 ////////////////////////////////////////////////////////////////////////////////
276 void Tracer::_traceCIMException(
277 const Uint32 traceComponent,
278 const Uint32 traceLevel,
279 CIMException cimException)
280 {
281 if ( traceLevel == LEVEL1 )
282 {
|
283 kumpf 1.14 trace( traceComponent, Tracer::LEVEL4, "%s", _LOG_MSG );
|
284 kumpf 1.5 }
285 else
286 {
287 if ( _isTraceEnabled( traceComponent, traceLevel ) )
288 {
289 // get the CIMException trace message string
|
290 kumpf 1.15 String traceMsg =
291 TraceableCIMException(cimException).getTraceDescription();
|
292 kumpf 1.5
293 // trace the string
294 _traceString(traceComponent, traceLevel, traceMsg);
|
295 mike 1.2 }
296 }
297 }
298
299 ////////////////////////////////////////////////////////////////////////////////
300 //Traces method entry
301 ////////////////////////////////////////////////////////////////////////////////
302 void Tracer::_traceEnter(
303 const char* fileName,
304 const Uint32 lineNum,
305 const Uint32 traceComponent,
306 const char* fmt,
307 ...)
308 {
309 va_list argList;
310 char* message;
311
312 if (_isTraceEnabled(traceComponent,LEVEL1))
313 {
|
314 kumpf 1.3
|
315 mike 1.2 va_start(argList,fmt);
316
|
317 kumpf 1.3 //
318 // Allocate memory for the message string
319 // Needs to be updated if additional info is added
320 //
|
321 chip 1.20 message = new char[ strlen(fileName) +
|
322 mday 1.19 _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ];
323
|
324 kumpf 1.3 sprintf(
325 message,
|
326 kumpf 1.9 "[%d:%u:%s:%u]: ",
|
327 kumpf 1.3 System::getPID(),
|
328 kumpf 1.9 Uint32(pegasus_thread_self()),
|
329 kumpf 1.3 fileName,
330 lineNum);
|
331 chip 1.20 _trace(traceComponent,message,fmt,argList);
|
332 mike 1.2
333 va_end(argList);
334 delete []message;
335 }
336 }
337
338 ////////////////////////////////////////////////////////////////////////////////
339 //Traces method exit
340 ////////////////////////////////////////////////////////////////////////////////
341 void Tracer::_traceExit(
342 const char* fileName,
343 const Uint32 lineNum,
344 const Uint32 traceComponent,
345 const char* fmt
346 ...)
347 {
348 va_list argList;
349 char* message;
350
351 if (_isTraceEnabled(traceComponent,LEVEL1))
352 {
353 mike 1.2 va_start(argList,fmt);
|
354 chip 1.20
|
355 kumpf 1.3 //
356 // Allocate memory for the message string
357 // Needs to be updated if additional info is added
358 //
|
359 chip 1.20 message = new char[ strlen(fileName) +
|
360 mday 1.19 _STRLEN_MAX_UNSIGNED_INT + (_STRLEN_MAX_PID_TID * 2) + 8 ];
361
|
362 kumpf 1.3 sprintf(
363 message,
|
364 kumpf 1.9 "[%d:%u:%s:%u]: ",
|
365 kumpf 1.3 System::getPID(),
|
366 kumpf 1.9 Uint32(pegasus_thread_self()),
|
367 kumpf 1.3 fileName,
368 lineNum);
|
369 chip 1.20 _trace(traceComponent,message,fmt,argList);
|
370 mike 1.2 va_end(argList);
371
372 delete []message;
373 }
374 }
375
376 ////////////////////////////////////////////////////////////////////////////////
377 //Checks if trace is enabled for the given component and level
378 ////////////////////////////////////////////////////////////////////////////////
379 Boolean Tracer::_isTraceEnabled(const Uint32 traceComponent,
380 const Uint32 traceLevel)
381 {
382 Tracer* instance = _getInstance();
383 if (traceComponent >= _NUM_COMPONENTS)
384 {
385 return false;
386 }
|
387 a.arora 1.22 return (((instance->_traceComponentMask.get())[traceComponent]) &&
|
388 mike 1.2 (traceLevel & instance->_traceLevelMask));
389 }
390
391 ////////////////////////////////////////////////////////////////////////////////
392 //Called by all trace interfaces to log message to trace file
393 ////////////////////////////////////////////////////////////////////////////////
394 void Tracer::_trace(
395 const Uint32 traceComponent,
396 const char* message,
397 const char* fmt,
398 va_list argList)
399 {
400 char* msgHeader;
401
402 // Get the current system time and prepend to message
403 String currentTime = System::getCurrentASCIITime();
|
404 kumpf 1.17 CString timeStamp = currentTime.getCString();
|
405 mike 1.2
|
406 kumpf 1.3 //
|
407 chip 1.20 // Allocate messageHeader.
|
408 kumpf 1.3 // Needs to be updated if additional info is added
409 //
|
410 mday 1.19
411
|
412 mike 1.2
413 // Construct the message header
|
414 chip 1.20 // The message header is in the following format
|
415 mike 1.2 // timestamp: <component name> [file name:line number]
416 if (strcmp(message,"") != 0)
417 {
|
418 mday 1.19 // << Wed Jul 16 10:58:40 2003 mdd >> _STRLEN_MAX_PID_TID is not used in this format string
419 msgHeader = new char [strlen(message)
|
420 chip 1.20 + strlen(TRACE_COMPONENT_LIST[traceComponent])
|
421 mday 1.19 + strlen(timeStamp) + _STRLEN_MAX_PID_TID + 5];
|
422 chip 1.20
|
423 kumpf 1.17 sprintf(msgHeader,"%s: %s %s",(const char*)timeStamp,
|
424 mike 1.2 TRACE_COMPONENT_LIST[traceComponent] ,message);
|
425 chip 1.20 //delete [] msgHeader;
|
426 mike 1.2 }
427 else
428 {
|
429 kumpf 1.3 //
430 // Since the message is blank form a string using the pid and tid
431 //
432 char* tmpBuffer;
433
434 //
|
435 chip 1.20 // Allocate messageHeader.
|
436 kumpf 1.3 // Needs to be updated if additional info is added
437 //
|
438 mday 1.19 tmpBuffer = new char[_STRLEN_MAX_PID_TID + 6];
|
439 kumpf 1.9 sprintf(tmpBuffer, "[%u:%u]: ", System::getPID(),
440 Uint32(pegasus_thread_self()));
|
441 chip 1.20 msgHeader = new char [ strlen(timeStamp) + strlen(TRACE_COMPONENT_LIST[traceComponent]) +
|
442 mday 1.19 strlen(tmpBuffer) + 1 + 5 ];
443
|
444 kumpf 1.17 sprintf(msgHeader,"%s: %s %s ",(const char*)timeStamp,
|
445 kumpf 1.3 TRACE_COMPONENT_LIST[traceComponent] ,tmpBuffer );
446 delete []tmpBuffer;
|
447 chip 1.20 //delete [] msgHeader;
|
448 mday 1.19
|
449 mike 1.2 }
450
451 // Call trace file handler to write message
452 _getInstance()->_traceHandler->handleMessage(msgHeader,fmt,argList);
|
453 chip 1.20
454 delete [] msgHeader;
|
455 mike 1.2 }
456
457 ////////////////////////////////////////////////////////////////////////////////
458 //Validate the trace file
459 ////////////////////////////////////////////////////////////////////////////////
|
460 kumpf 1.10 Boolean Tracer::isValidFileName(const char* filePath)
|
461 mike 1.2 {
|
462 kumpf 1.23 String moduleName = _getInstance()->_moduleName;
463 if (moduleName == String::EMPTY)
464 {
465 return (_getInstance()->_traceHandler->isValidFilePath(filePath));
466 }
467 else
468 {
469 String extendedFilePath = String(filePath) + "." + moduleName;
470 return (_getInstance()->_traceHandler->isValidFilePath(
471 extendedFilePath.getCString()));
472 }
|
473 mike 1.2 }
474
475 ////////////////////////////////////////////////////////////////////////////////
476 //Validate the trace components
477 ////////////////////////////////////////////////////////////////////////////////
|
478 kumpf 1.23 Boolean Tracer::isValidComponents(const String& traceComponents)
|
479 kumpf 1.10 {
480 String invalidComponents;
481 return isValidComponents(traceComponents, invalidComponents);
482 }
483
484 Boolean Tracer::isValidComponents(
|
485 kumpf 1.23 const String& traceComponents, String& invalidComponents)
|
486 mike 1.2 {
487 // Validate the trace components and modify the traceComponents argument
488 // to reflect the invalid components
489
490 Uint32 position=0;
491 Uint32 index=0;
492 String componentName = String::EMPTY;
493 String componentStr = String::EMPTY;
494 Boolean validComponent=false;
495 Boolean retCode=true;
496
497 componentStr = traceComponents;
498 invalidComponents = String::EMPTY;
499
500 if (componentStr != String::EMPTY)
501 {
502 // Check if ALL is specified
503 if (String::equalNoCase(componentStr,"ALL"))
504 {
505 return _SUCCESS;
506 }
507 mike 1.2
508 // Append _COMPONENT_SEPARATOR to the end of the traceComponents
|
509 kumpf 1.16 componentStr.append(_COMPONENT_SEPARATOR);
|
510 mike 1.2
511 while (componentStr != String::EMPTY)
512 {
513 //
514 // Get the Component name from traceComponents.
515 // Components are separated by _COMPONENT_SEPARATOR
516 //
517 position = componentStr.find(_COMPONENT_SEPARATOR);
518 componentName = componentStr.subString(0,(position));
519
520 // Lookup the index for Component name in TRACE_COMPONENT_LIST
521 index = 0;
522 validComponent = false;
523
524 while (index < _NUM_COMPONENTS)
525 {
|
526 chip 1.20 if (String::equalNoCase(
|
527 mike 1.2 componentName, TRACE_COMPONENT_LIST[index]))
528 {
529 // Found component, break from the loop
530 validComponent = true;
531 break;
532 }
533 else
534 {
535 index++;
536 }
537 }
538
539 // Remove the searched componentname from the traceComponents
540 componentStr.remove(0,position+1);
541
542 if ( !validComponent )
543 {
|
544 kumpf 1.16 invalidComponents.append(componentName);
545 invalidComponents.append(_COMPONENT_SEPARATOR);
|
546 mike 1.2 }
547 }
548 }
549 else
550 {
551 // trace components is empty, it is a valid value so return true
552 return _SUCCESS;
553 }
554 if ( invalidComponents != String::EMPTY )
555 {
556 retCode = false;
557 //
558 // Remove the extra ',' at the end
559 //
560 invalidComponents.remove(
561 invalidComponents.reverseFind(_COMPONENT_SEPARATOR));
562 }
563 return retCode;
564 }
|
565 chip 1.20
|
566 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
|
567 kumpf 1.23 //Set the name of the module being traced
568 ////////////////////////////////////////////////////////////////////////////////
569 void Tracer::setModuleName(const String& moduleName)
570 {
571 _getInstance()->_moduleName = moduleName;
572 }
573
574 ////////////////////////////////////////////////////////////////////////////////
|
575 mike 1.2 //Returns the Singleton instance of the Tracer
576 ////////////////////////////////////////////////////////////////////////////////
577 Tracer* Tracer::_getInstance()
578 {
579 if (_tracerInstance == 0)
580 {
581 _tracerInstance = new Tracer();
582 }
583 return _tracerInstance;
584 }
585
|
586 chip 1.20 // PEGASUS_REMOVE_TRACE defines the compile time inclusion of the Trace
|
587 mike 1.2 // interfaces. If defined the interfaces map to empty functions
588
589 #ifndef PEGASUS_REMOVE_TRACE
590
591 ////////////////////////////////////////////////////////////////////////////////
592 //Set the trace file
593 ////////////////////////////////////////////////////////////////////////////////
594 Uint32 Tracer::setTraceFile(const char* traceFile)
595 {
|
596 kumpf 1.23 String moduleName = _getInstance()->_moduleName;
597 if (moduleName == String::EMPTY)
598 {
599 return (_getInstance()->_traceHandler->setFileName(traceFile));
600 }
601 else
602 {
603 String extendedTraceFile = String(traceFile) + "." + moduleName;
604 return (_getInstance()->_traceHandler->setFileName(
605 extendedTraceFile.getCString()));
606 }
|
607 chip 1.20 }
|
608 mike 1.2
609 ////////////////////////////////////////////////////////////////////////////////
610 //Set the trace level
611 ////////////////////////////////////////////////////////////////////////////////
612 Uint32 Tracer::setTraceLevel(const Uint32 traceLevel)
613 {
614 Uint32 retCode = 0;
615
616 switch (traceLevel)
617 {
618 case LEVEL1:
619 _getInstance()->_traceLevelMask = 0x01;
620 break;
|
621 chip 1.20
|
622 mike 1.2 case LEVEL2:
623 _getInstance()->_traceLevelMask = 0x03;
624 break;
625
626 case LEVEL3:
627 _getInstance()->_traceLevelMask = 0x07;
628 break;
629
630 case LEVEL4:
631 _getInstance()->_traceLevelMask = 0x0F;
632 break;
633
634 default:
635 _getInstance()->_traceLevelMask = 0;
636 retCode = 1;
637 }
638 return retCode;
639 }
640
641 ////////////////////////////////////////////////////////////////////////////////
|
642 chip 1.20 // Set components to be traced.
|
643 mike 1.2 ////////////////////////////////////////////////////////////////////////////////
|
644 kumpf 1.23 void Tracer::setTraceComponents(const String& traceComponents)
|
645 mike 1.2 {
646 Uint32 position = 0;
647 Uint32 index = 0;
648 String componentName = String::EMPTY;
649 String componentStr = traceComponents;
650 String invalidComponents = String::EMPTY;
|
651 chip 1.20
|
652 mike 1.2 if (componentStr != String::EMPTY)
653 {
654 // Check if ALL is specified
655 if (String::equalNoCase(componentStr,"ALL"))
656 {
657 for (index=0; index < _NUM_COMPONENTS;
|
658 a.arora 1.22 (_getInstance()->_traceComponentMask.get())[index++] = true);
|
659 chip 1.20 return ;
|
660 mike 1.2 }
661
662 // initialise ComponentMask array to False
|
663 chip 1.20 for (index = 0;index < _NUM_COMPONENTS;
|
664 a.arora 1.22 (_getInstance()->_traceComponentMask.get())[index++] = false);
|
665 mike 1.2
666 // Append _COMPONENT_SEPARATOR to the end of the traceComponents
|
667 kumpf 1.16 componentStr.append(_COMPONENT_SEPARATOR);
|
668 mike 1.2
669 while (componentStr != String::EMPTY)
670 {
|
671 chip 1.20 // Get the Component name from traceComponents.
|
672 mike 1.2 // Components are separated by _COMPONENT_SEPARATOR
673 position = componentStr.find(_COMPONENT_SEPARATOR);
674 componentName = componentStr.subString(0,(position));
675
676 // Lookup the index for Component name in TRACE_COMPONENT_LIST
677 index = 0;
678 while (index < _NUM_COMPONENTS)
679 {
680 if (String::equalNoCase(
681 componentName,TRACE_COMPONENT_LIST[index]))
682 {
|
683 a.arora 1.22 (_getInstance()->_traceComponentMask.get())[index]=true;
|
684 mike 1.2
685 // Found component, break from the loop
686 break;
687 }
688 else
689 {
690 index++;
691 }
|
692 chip 1.20 }
|
693 mike 1.2
694 // Remove the searched componentname from the traceComponents
695 componentStr.remove(0,position+1);
696 }
697 }
698 else
699 {
700 // initialise ComponentMask array to False
|
701 chip 1.20 for (Uint32 index = 0;index < _NUM_COMPONENTS;
|
702 a.arora 1.22 (_getInstance()->_traceComponentMask.get())[index++] = false);
|
703 mike 1.2 }
704 return ;
705 }
706
707 #endif
708
709 PEGASUS_NAMESPACE_END
|