Qore Logger Module Reference 0.6
Loading...
Searching...
No Matches
Logger::LoggerEvent Class Reference

Implements an event to be logged. More...

#include <Logger.qm.dox.h>

Public Member Methods

 constructor (Logger logger, LoggerLevel level, string message, *list< auto > args, *hash< CallStackInfo > location_info, int thread_id=gettid(), date time_stamp=now_us(), *hash< ExceptionInfo > throwable)
 Instantiates a LoggingEvent from the supplied parameters. More...
 
 constructor (string fqcn, softstring category, LoggerLevel level, string message, *list< auto > args, *hash< CallStackInfo > location_info, int thread_id=gettid(), date time_stamp=now_us(), *hash< ExceptionInfo > 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< auto > 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  logger,
LoggerLevel  level,
string  message,
*list< auto >  args,
*hash< CallStackInfo >  location_info,
int  thread_id = gettid(),
date  time_stamp = now_us(),
*hash< ExceptionInfo >  throwable 
)

Instantiates a LoggingEvent from the supplied parameters.

The category becomes logger name and fqcn logger class name

Parameters
loggerInstance of the Logger class
levelThe event level
messageThe payload as format for sprintf()()
argsThe arguments for formatting
location_infocode location related to logging event
thread_idthread related to the event, Default: gettid()
time_stamplogging event timestamp. Default value is now_us()
throwableThe throwable ExceptionInfo associated with the logging event

◆ constructor() [2/2]

Logger::LoggerEvent::constructor ( string  fqcn,
softstring  category,
LoggerLevel  level,
string  message,
*list< auto >  args,
*hash< CallStackInfo >  location_info,
int  thread_id = gettid(),
date  time_stamp = now_us(),
*hash< ExceptionInfo >  throwable 
)

Instantiates a LoggingEvent from the supplied parameters.

Parameters
fqcnname of the caller class.
categoryThe event category.
levelThe event level
messageThe payload as format for sprintf()()
argsThe arguments for formatting
location_infocode location related to logging event
thread_idthread related to the event, Default: gettid()
time_stamplogging event timestamp. Default value is now_us()
throwableThe throwable ExceptionInfo associated with the 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()