Qore Logger Module Reference  0.1.1
Logger::LoggerEvent Class Reference

Implements an event to be logged. More...

Public Member Methods

 constructor (Logger n_logger, LoggerLevel n_level, string n_message, *list n_args, *hash< CallStackInfo > n_location_info, int n_thread_id=gettid(), date n_time_stamp=now_us(), *hash< ExceptionInfo > n_throwable)
 Instantiates a LoggingEvent from the supplied parameters. More...
 
 constructor (string n_fqcn, softstring n_category, LoggerLevel n_level, string n_message, *list n_args, *hash< CallStackInfo > n_location_info, int n_thread_id=gettid(), date n_time_stamp=now_us(), *hash< ExceptionInfo > n_throwable)
 Instantiates a LoggingEvent from the supplied parameters. More...
 
string getCategoryName ()
 Returns the category name.
 
string getFullQualifiedClassname ()
 Returns the full qualified classname.
 
LoggerLevel getLevel ()
 Returns the level of this event.
 
*hash< CallStackInfo > getLocationInfo ()
 Returns the location information for this logging event.
 
*Logger getLogger ()
 Returns the logger which created the event.
 
string getMessage ()
 Returns the string message for the logging event. More...
 
date getRelativeTime ()
 Returns a relative timestamp for the event. More...
 
int getThreadId ()
 Returns the thread id which is related to event.
 
*hash< ExceptionInfo > getThrowableInfo ()
 Returns throwable info, if any.
 
date getTimeStamp ()
 Returns the event timestamp as an absolute date/time value.
 
int getUniqueId ()
 Generates a globally unique integer identifier and associates it to the event.
 

Static Public Member Methods

static date getStartTime ()
 Returns the time when the application/logger started to calculate relative time.
 
static setStartTime (date time)
 Sets the starting time for relative time.
 

Static Private:Internal Member Methods

static Sequence sequence (1)
 unique id generator
 

Private:Internal Attributes

string categoryName
 The category (logger) name.
 
string fqcn
 Fully Qualified Class Name of the calling category class.
 
LoggerLevel level
 Level of the logging event.
 
*hash< CallStackInfo > locationInfo
 location information where the logging was performed.
 
*Logger logger
 Logger reference.
 
*list messageArgs
 arguments to be rendered
 
string messageFmt
 The application supplied message of logging event (not rendered)
 
*string renderedMessage
 The application supplied message rendered through the rendering mechanism.
 
int threadId
 related thread id
 
*hash< ExceptionInfo > throwableInfo
 internal representation of throwable
 
date timeStamp
 event time stamp
 
int uniqueId
 unique id
 

Static Private:Internal Attributes

static date startTime = now_us()
 origin stamp to calculate relative time
 

Detailed Description

Implements an event to be logged.

The event data consists of format string and parameters. The output string is rendered at time when logging decision to target is made. Callable parameters are evaluated at this moment as well. It should be considered when callable parameters do not return time persistent value. When callable raises an exception then exception instance is passed for formatting. So it should be considered if format string and use for example "%y" to get readable data.

Member Function Documentation

◆ constructor() [1/2]

Logger::LoggerEvent::constructor ( Logger  n_logger,
LoggerLevel  n_level,
string  n_message,
*list  n_args,
*hash< CallStackInfo >  n_location_info,
int  n_thread_id = gettid(),
date  n_time_stamp = now_us(),
*hash< ExceptionInfo >  n_throwable 
)

Instantiates a LoggingEvent from the supplied parameters.

The category becomes logger name and fqcn logger class name

Parameters
n_loggerInstance of the Logger class
n_levelThe event level
n_messageThe payload as format for sprintf()
n_argsThe arguments for formatting
n_location_infocode location related to logging event
n_thread_idthread related to the event, Default: gettid()
n_time_stamplogging event timestamp. Default value is now_us
n_throwableThe throwable ExceptionInfo associated with logging event

◆ constructor() [2/2]

Logger::LoggerEvent::constructor ( string  n_fqcn,
softstring  n_category,
LoggerLevel  n_level,
string  n_message,
*list  n_args,
*hash< CallStackInfo >  n_location_info,
int  n_thread_id = gettid(),
date  n_time_stamp = now_us(),
*hash< ExceptionInfo >  n_throwable 
)

Instantiates a LoggingEvent from the supplied parameters.

Parameters
n_fqcnname of the caller class.
n_categoryThe event category.
n_levelThe event level
n_messageThe payload as format for sprintf()
n_argsThe arguments for formatting
n_location_infocode location related to logging event
n_thread_idthread related to the event, Default: gettid()
n_time_stamplogging event timestamp. Default value is now_us
n_throwableThe throwable ExceptionInfo associated with logging event

◆ getMessage()

string Logger::LoggerEvent::getMessage ( )

Returns the string message for the logging event.

Potential callable references are evaluated. Next the message is rendered using vsprintf() and the result is cached, so the message is rendered only once.

Returns
the rendered message

◆ getRelativeTime()

date Logger::LoggerEvent::getRelativeTime ( )

Returns a relative timestamp for the event.

Returns a relative date/time value for the amount of time passed from the beginning of execution to the time when the event was constructed.

See also
getStartTime()