[ANN] Toothpick

goran at krampe.se goran at krampe.se
Fri Nov 3 06:55:27 UTC 2006


Hi all!

"Torsten Bergmann" <astares at gmx.de> wrote:
> Toothpick - a simple configurable Logging mechanism for Smalltalk 
> is now also available as Monticello package on SqueakSource 
> and SqueakMap. I just converted the source zip into a monticello 
> package with kindly permission from Joseph Pelrine. His code is 
> released under BSD license.

Great!

I also saw this (from the Bern day) and intend to take a look but just
wanted to mention:

Gjallar has a small logging solution inside that would be interesting to
compare/merge with this. It is small (4 classes IIRC) and has a Morphic
tool as one of the backends. The next step would have been adding
syslogd UDP to it - but I think Toothpick has this so it would be more
interesting in merging I guess.

If anyone wants to tackle this contact me or the setools list - the
logging parts in Gjallar should be totally separate, but is not packaged
separate right now (Q2Log, Q2LogFile, Q2LogMorph).

It is not obvious that a merge is best - Q2Log (and friends) is very
small and Squeak specific - both of which can be advantages compared to
Toothpick. But Toothpick is obviously more capable.

I include the class comment of Q2Log below.

regards, Göran

PS. There is also at least one more logger on SM. Btw, ripping out UDP
code from Toothpick and adding that to Q2Log in the next 7 days would be
a strong candidate for the Ipod competition.... :) Or any other
interesting combo - like rewriting Q2Log as a facade to Toothpick, or
whatever.

---------------------------------------
Nice and simple logging. There are eight messages for logging based on
severity. These correspond to the eight levels defined in syslog:

7 - debug (Debug-level messages)
6 - info (Informational)
5 - notice (Normal but significant Condition)
4 - warning (Warning Condition)
3 - err (Error Condition)
2 - crit (Critical Conditions)
1 - alert (must be handled immediately)
0 - emerg (System is unusable)
	
The absolutely easiest way to log is like this:

	Q2Log warn: 'Oopsidaisy'

We only need to include the actual message in the string, timestamp etc
is added automatically.
You can also explicitly supply a "sender" object which can be anything
you like, a symbol or a specific domain object even:

	Q2Log warn: 'Yowsa' sender: #email

Q2Log uses printString on the sender when producing the log entry, so if
you use domain objects - make sure they have a unique printOn: method
defined so that you can distinguish them. See class side category
"logging" and "logging shorthand" for the available log messages.

By default there is a single emitter registered that logs on Transcript,
you can turn this off with:

	Q2Log useTranscript: false

And you can set a threshold for the above 8 syslog levels that should be
logged onto Transcript using:

	Q2Log instance transcriptMaxLevel: 4

..or set a global threshold for all emitters:

	Q2Log instance globalMaxLevel: 4

Global flushing of all emitters can be done using "Q2Log flush" and
should ideally be called regularly by some background process.

Finally take a look at Q2LogFile for details on how to add it as an
emitter to get logging onto file instead of Transcript, and Q2LogMorph
for getting logging into a very nice UI that offers filtering, searching
etc.



More information about the Squeak-dev mailing list