#include <OTC/debug/tracetag.hh> class OTC_TraceTag : public OTC_TraceSwitch {
public:
inline ~OTC_TraceTag();
OTC_TraceTag(char const* theName);
OTC_Boolean enabled() const;
inline int level() const;
inline char const* name() const;
static int set(char const* theName, int theLevel=0);
inline static OTC_TagInfo* switches();
OTC_TraceSwitch operator==(int theLevel) const;
OTC_TraceSwitch operator!=(int theLevel) const;
OTC_TraceSwitch operator<(int theLevel) const;
OTC_TraceSwitch operator<=(int theLevel) const;
OTC_TraceSwitch operator>(int theLevel) const;
OTC_TraceSwitch operator>=(int theLevel) const;
};
OTC_TraceTag
is a named version of a trace switch. The
name allows the status of the switch to be set through either an
environment variable, or program control. In addition, a trace
level may be associated with the named switch, when used in
conjunction with the comparison and logic operators, the trace
level allows expressions to be used to determine if trace output
should be generated for a particular statement. For example:
main()
{
OTC_TraceSwitch LIBRARY("LIBRARY");
OTC_TraceSwitch PROGRAM("PROGRAM");
OTCLIB_TRACER(LIBRARY || PROGRAM > 4) << "some text" << endl;
return 0;
}
The status of a named switch can be set using the environment
variable OTCLIB_TRACETAGS
. When set, the environment variable
should contain a list of the named switches which should be
enabled. You may optionally include an assignment in the list
to set the trace level of a switch to a defined value. If you
do not set the trace level of a switch, it will default to 0
.
If multiple trace tag names are listed they should be separated
by a single space.
OTCLIB_TRACETAGS="PROGRAM=5 LIBRARY" program
Macros are provided to allow you to create named switches. Code
for these macros will be compiled into your code, only
if the preprocessor symbol OTCLIB_TRACE
is defined. These
macros are OTCLIB_TRACETAG
, OTCLIB_STATIC_TRACETAG
and OTCLIB_SETRACETAG
. The macro OTCLIB_STATIC_TRACEPATTERN
creates an instance of the class which has static extent.
OTCLIB_SETTRACETAG
is provided to allow you to set the trace
level of a switch in your program. Setting the trace level of a
switch, will result in all switches of that name in your program
being updated.
OTCLIB_STATIC_TRACETAG(PROGRAM);
main()
{
OTCLIB_TRACETAG(MAIN);
OTCLIB_TRACER(PROGRAM) << "some text" << endl;
OTCLIB_SETTRACETAG(MAIN,0); // Make sure MAIN is enabled.
OTCLIB_TRACER(MAIN || PROGRAM) << "some text" << endl;
}
OTC_TraceTag(char const* theName);
theName
.
OTC_Boolean enabled() const;
OTCLIB_TRUE
if the switch is
enabled.
inline int level() const;
inline char const* name() const;
static int set(char const* theName, int theLevel=0);
theName
to theLevel
.
inline static OTC_TagInfo* switches();
OTC_TraceSwitch operator==(int theLevel) const;
theLevel
.
OTC_TraceSwitch operator!=(int theLevel) const;
theLevel
.
OTC_TraceSwitch operator<(int theLevel) const;
theLevel
.
OTC_TraceSwitch operator<=(int theLevel) const;
theLevel
.
OTC_TraceSwitch operator>(int theLevel) const;
theLevel
.
OTC_TraceSwitch operator>=(int theLevel) const;
theLevel
.
OTC_TraceSwitch
, OTC_TagInfo