GPL_Logger
GPL_Logger
gpl
1998 12-05
CLASS
GPL_Logger - C++ logging mechanism
SYNOPSIS
The logger maintains a set of valid log types denoted by strings. The
log types are associated with a number of delivery mechanisms (see
GPL_Delivery). When the Log() method is used to 'log' a
message the message is routed to the delivery mechanisms associated with
the specified type. If the specified type is not valid (it is not in
the registered set) the message is sent to a default delivery mechanism.
Delivery mechanisms are themselves named by strings and are looked up by
their names when the Log() method is used. This lookup can be
avoided by using DirectLog().
CONSTRUCTOR
GPL_Logger(void)
Create a GPL_Logger. This is typically done automatically within
a GPL_Application construction.
This also creates the following deliveries (see SetDelivery():
| BUILTIN_NOOP |
GPL_DeliveryNoop
|
| BUILTIN_OSD_OUTPUT |
GPL_DeliveryOsdOutput
|
| BUILTIN_OSD_OUTPUT_TERSE |
GPL_DeliveryOsdOutputTerse
|
| BUILTIN_PRINTF |
GPL_DeliveryPrintf
|
| BUILTIN_PRINTF_TERSE |
GPL_DeliveryPrintfTerse
|
| BUILTIN_EXIT |
GPL_DeliveryExit
|
MEMBER FUNCTIONS
void SetDefaultDelivery(GPL_Delivery *delivery)
Set the default delivery mechanism. The 'default' default delivery
mechanism is GPL_DeliveryPrintf.
void SetDelivery(const GPL_String &name, GPL_Delivery *delivery = NULL)
Set the delivery associated with name.
void SetType(const GPL_String &typename, int deliveries = 0, ...)
Set the delivery names associated with typename. The number of
delivery names is specified by deliveries which is followed by the
char * names.
void Log(const GPL_String &filename, long linenum, const GPL_String &typename, const char *format, ...)
Send the message to all delivery mechanism associated with typename.
void VLog(const GPL_String &filename, long linenum, const GPL_String &typename, const char *format, va_list args)
A va_list variant of Log().
void DirectLog(GPL_Delivery *delivery, const GPL_String &filename, long linenum, const GPL_String &typename, const char *format, ...)
Send the message only to the specified delivery. If
delivery is NULL send to the default delivery.
void DirectVLog(GPL_Delivery *delivery, const GPL_String &filename, long linenum, const GPL_String &typename, const char *format, va_list args)
A va_list variant of DirectLog().
MACROS
GPL_LOGGER
This is the equivalent of GPL_Application::GetCurrentApplication()->logger
gplLog(char *type, char *format, ...)
Calls Log() for the
Logger in the current GPL_Application.
Note that this macro is not line safe. In other words, this macro does
not safely expand as a single line or scope of code. Therefore, the
following line will probably not act as intended:
if(SoAndSoIsTrue()) gplLog("type", "message");
and should be written as:
if(SoAndSoIsTrue()) { gplLog("type", "message"); }
gplDLog(GPL_Delivery *delivery, char *type, char *format, ...)
The same as gplLog
except DirectLog() is called instead of Log().