The Toothpick Logo

Logging Events

A LoggingEvent is what is says it is, namely, an object that captures information on an event so that it can be logged. The event can be anything you want to be logged, it doesn't have to be an Event.

A LoggingEvent contains a few obvious pieces of information. First of all, it has a Timestamp, which records when the event occurred. The timestamp is set automatically when the LoggingEvent instance is created; you don't need to set it yourself. Secondly, a LoggingEvent normally contains a message String which provides some information about the event. You provide this String when instantiating the event.

Previous implementations of LoggingEvent have tracked the logging context and exceptions raised, and these instance variables, although not used, have been kept in the current implementation.

Categories and levels

A category is a Symbol describing which type of event you're logging. You can freely choose the category symbol for your logging events. Typical categories might be #debug, #perf, etc.

In contrast the logging level symbols are taken from a fixed set that matches the conventions of several operating systems. This fixed set of levels is declared in

LoggingEvent class>>#allLevels
		^#(#all #debug #info #notice #warn #error #crit 
		#alert #emerg #panic #fatal #off #none)

With the standard LoggingPolicy, events are logged if their category matches the category of the Policy, and if the level is equal to, or higher than, the level of the Policy. This means that e.g., a LoggingPolicy with a level of #debug will log an event with level #info, while a LoggingPolicy with a level of #error will not. Both will log events with a level #fatal.

Instance Variables:

category <Symbol> A freely chooseable Symbol describing the type of event, such as #debug or #performance
context <String | Symbol> A String or Symbol describing the logging context.
exception <Exception> A placeholder, currently unused
level <Symbol> A Symbol describing the level. For possible levels, and their order, see the section "Categories and Levels" above.
message <String> A text describing the event.
timeStamp <Timestamp> A TimeStamp, what else.

Published Thursday, October 19, 2006
supported dialects