version 1.17, 2005/01/19 23:48:05
|
version 1.20, 2005/11/14 12:57:27
|
|
|
//%2004//////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development | // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. | // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
|
// IBM Corp.; EMC Corporation, The Open Group. | // IBM Corp.; EMC Corporation, The Open Group. |
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; | // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
#define Pegasus_Tracer_h | #define Pegasus_Tracer_h |
| |
#include <stdarg.h> | #include <stdarg.h> |
#include <fstream> |
|
#include <Pegasus/Common/String.h> | #include <Pegasus/Common/String.h> |
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
#include <Pegasus/Common/Logger.h> | #include <Pegasus/Common/Logger.h> |
|
|
const char* data, | const char* data, |
const Uint32 size) | const Uint32 size) |
{ | { |
|
if (_traceOn) |
|
{ |
_traceBuffer( traceComponent, traceLevel, data, size ); | _traceBuffer( traceComponent, traceLevel, data, size ); |
} | } |
|
} |
| |
/** Traces the specified number of bytes in a given buffer | /** Traces the specified number of bytes in a given buffer |
Overloaded to include the filename and the line number | Overloaded to include the filename and the line number |
|
|
const char* data, | const char* data, |
const Uint32 size) | const Uint32 size) |
{ | { |
|
if (_traceOn) |
|
{ |
_traceBuffer( fileName, lineNum, | _traceBuffer( fileName, lineNum, |
traceComponent, traceLevel, data, size ); | traceComponent, traceLevel, data, size ); |
} | } |
|
} |
| |
| |
/** Traces the given message | /** Traces the given message |
|
|
const char *fmt, | const char *fmt, |
...) | ...) |
{ | { |
|
if (_traceOn) |
|
{ |
va_list argList; | va_list argList; |
| |
va_start(argList,fmt); | va_start(argList,fmt); |
_trace(traceComponent,traceLevel,fmt,argList); | _trace(traceComponent,traceLevel,fmt,argList); |
va_end(argList); | va_end(argList); |
} | } |
|
} |
| |
/** Traces the given message. Overloaded to include the filename and | /** Traces the given message. Overloaded to include the filename and |
the line number of trace origin. | the line number of trace origin. |
|
|
const char* fmt, | const char* fmt, |
...) | ...) |
{ | { |
|
if (_traceOn) |
|
{ |
va_list argList; | va_list argList; |
| |
va_start(argList,fmt); | va_start(argList,fmt); |
_trace(fileName,lineNum,traceComponent,traceLevel,fmt,argList); | _trace(fileName,lineNum,traceComponent,traceLevel,fmt,argList); |
va_end(argList); | va_end(argList); |
} | } |
|
} |
| |
/** Traces the given string. Overloaded to include the filename | /** Traces the given string. Overloaded to include the filename |
and line number of trace origin. | and line number of trace origin. |
|
|
const Uint32 traceLevel, | const Uint32 traceLevel, |
const String& traceString) | const String& traceString) |
{ | { |
|
if (_traceOn) |
|
{ |
_traceString( fileName, lineNum, traceComponent, traceLevel, | _traceString( fileName, lineNum, traceComponent, traceLevel, |
traceString ); | traceString ); |
} | } |
|
} |
| |
/** Traces the message in the given CIMException object. The message | /** Traces the message in the given CIMException object. The message |
written to the trace file will include the source filename and | written to the trace file will include the source filename and |
|
|
const Uint32 traceLevel, | const Uint32 traceLevel, |
CIMException cimException) | CIMException cimException) |
{ | { |
|
if (_traceOn) |
|
{ |
_traceCIMException( traceComponent, traceLevel, cimException ); | _traceCIMException( traceComponent, traceLevel, cimException ); |
} | } |
|
} |
| |
/** Set the trace file to the given file | /** Set the trace file to the given file |
@param traceFile full path of the trace file | @param traceFile full path of the trace file |
|
|
const Uint32 traceComponent, | const Uint32 traceComponent, |
const char* methodName) | const char* methodName) |
{ | { |
|
if (_traceOn) |
|
{ |
_traceEnter( fileName, lineNum, traceComponent, "%s %s", | _traceEnter( fileName, lineNum, traceComponent, "%s %s", |
_METHOD_ENTER_MSG, methodName); | _METHOD_ENTER_MSG, methodName); |
} | } |
|
} |
| |
/** Traces method exit. | /** Traces method exit. |
@param fileName filename of the trace originator | @param fileName filename of the trace originator |
|
|
const Uint32 traceComponent, | const Uint32 traceComponent, |
const char* methodName) | const char* methodName) |
{ | { |
|
if (_traceOn) |
|
{ |
_traceExit( fileName, lineNum, traceComponent, "%s %s", | _traceExit( fileName, lineNum, traceComponent, "%s %s", |
_METHOD_EXIT_MSG, methodName); | _METHOD_EXIT_MSG, methodName); |
} | } |
|
} |
| |
/** Validates the File Path for the trace File | /** Validates the File Path for the trace File |
@param filePath full path of the file | @param filePath full path of the file |
|
|
| |
private: | private: |
| |
|
/** A static single indicator if tracing is turned on allowing to |
|
determine the state of trace quickly without many instructions. |
|
Used to wrap the public static trace interface methods to avoid |
|
obsolete calls when tracing is turned off. |
|
*/ |
|
static Uint32 _traceOn; |
|
|
static const char _COMPONENT_SEPARATOR; | static const char _COMPONENT_SEPARATOR; |
static const Uint32 _NUM_COMPONENTS; | static const Uint32 _NUM_COMPONENTS; |
static const Uint32 _STRLEN_MAX_UNSIGNED_INT; | static const Uint32 _STRLEN_MAX_UNSIGNED_INT; |