Examples and Code Snippets
Here are a few code snippets which I use for testing the framework, but which haven't yet made it into a test suite.
The following snippet loads the file toothpick.ini and configures the loggers from it. It then triggers an error-level LoggingEvent, which should be picked up and logged by all loggers. Afterwards, all loggers are stopped, and the LoggingMultiplexer reset.
LoggingMultiplexer reset. LoggingMultiplexer current configureFromIniFile; startAllLoggers. LoggingEvent logError: 'Test Message'. LoggingMultiplexer current stopAllLoggers. LoggingMultiplexer reset.
We used this test to implement and debug the mutex queue.
This snippet shows how easily Toothpick integrates with the standard Smalltalk event mechanism.
| logger foo | LoggingMultiplexer reset. logger := TranscriptLogger new policy: LoggingPolicy debugPolicy; yourself. LoggingMultiplexer current addLogger: logger; startAllLoggers. foo := Object new. foo when: #ping: send: #logWarn: to: LoggingEvent. foo triggerEvent: #ping: with: 'Hello World'
Published Thursday, October 19, 2006