The Toothpick Logo

Logging Policies

A LoggingPolicy defines which events will be logged. This is most often based on the criteria of category and level.

A LoggingPolicy decides whether or not to log an event by evaluating a one-argument block, the isInterestingBlock, with the event. Here is the implementation of the default isInterestingBlock:


	^ [ :event | event category == self category and: [ 
				 event isLevelHigherThan: self level ]]

You can configure your own LoggingPolicy by defining a custom isInterestingBlock. The isInterestingBlock for the class-side convenience #debugPolicy looks like this:

	[ :event | event isLevelHigherThan: #debug ]

This policy will log all events with a level greater or equal to #debug, regardless of category. For a discussion of categories, see here.

[top]  [home]


For tricky logging situations, you should use a CompositeLoggingPolicy.

Published Thursday, October 19, 2006
supported dialects