<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">I needed a simple logging framework for the webserver - there is a bunch of partial ‘warning:’ ‘error:’ etc methods spread about the image but mostly they just print raw strings to stdout. I’ve written a very simple one which allows for pluggable handlers. It’s currently in the ‘logging’ branch on <a href="http://github.com/russellallen/self" class="">github.com/russellallen/self</a></div><div class=""><br class=""></div><div class="">Below is the, um, somewhat minimal documentation.</div><div class=""><br class=""></div><div class="">If you want to look at it, checkout the logging branch, then build a new snapshot. Then have a look at the ‘log’ slot of globals.</div><div class=""><br class=""></div><div class="">Any feedback would be great. If people think this is a good idea I’d like to merge it (or something like it) into the main branch for the next release.  </div><div class=""><br class=""></div><div class="">Cheers, Russell</div><div class=""><br class=""></div><div class=""><div class="">Logging</div><div class="">=======</div><div class=""><br class=""></div><div class="">``log`` is a useful system-wide logging mechanism. You can find it in the ``system`` category of ``globals``.</div><div class=""><br class=""></div><div class="">How to log </div><div class="">----------</div><div class=""><br class=""></div><div class="">There are a number of useful messages in the ``logging`` category of ``log`` which allow you to simply and cleanly log messages. For example::</div><div class=""><br class=""></div><div class="">  log warn: 'This is a warning.'</div><div class="">  </div><div class="">You can log with one of five levels found at ``log levels``. These are, in order of severity, ``debug``, ``info``, ``warn``, ``error``, ``fatal``.</div><div class=""><br class=""></div><div class="">You can also tag log entries, for example::</div><div class=""><br class=""></div><div class="">  log fatal: 'The server has caught fire' For: 'webserver'</div><div class="">  </div><div class="">By default, entries of either error or fatal severity which aren't tagged are logged to stderr in the form::</div><div class=""><br class=""></div><div class="">  [Thu Oct 23 16:25:07 2014] error -- Something went wrong!</div><div class="">  </div><div class="">How logging works</div><div class="">-----------------</div><div class=""><br class=""></div><div class="">The helper methods shown above constuct a ``log entry`` and hand it to the ``log dispatcher``. The dispatcher has a number of handlers, each is given a chance to handle the log entry. The handlers can choose which entries to act on. Example handlers are in ``log prototypeHandlers``.</div><div class=""><br class=""></div><div class="">When making a handler, please keep in mind that the log entry's ``message`` is expected to be something which understands ``value``, returning an object (or itself) which understands ``asString``. If you do not need to resolve the message by sending it ``value`` please don't; that way logs can be sent blocks which are only resolved if necessary; eg::</div><div class=""><br class=""></div><div class="">  log debug: ['We have reached: ', somethingComplicatedToCalculate]</div><div class="">  </div><div class="">will not slow down your code if no log handler is interested in handling debuggers.</div><div class=""><br class=""></div><div class="">If your handler breaks the logging process you can restart it by::</div><div class=""><br class=""></div><div class="">  log dispatcher hup</div></div><div class=""><br class=""></div></body></html>