stxnext.log
Overview
Logger is written from scratch. It offers a few facilities that helps logging (e.g.: logging exceptions). It can also log some messages from ZPT (Zope Page Templates).
Usage
stxnext.log can be opened from python code:
>>> from stxnext.log import log
>>> log('log <this> text')
>>> log('log another text', printit=True) #doctest:+ELLIPSIS
[...] log another text
>>> try:
... 1/0
... except ZeroDivisionError, e:
... log.log_exc(e)
...
>>> log.getLoggedTextAsHtml() #doctest:+ELLIPSIS, +NORMALIZE_WHITESPACE
<pre>[...] log <this> text...</pre>
stxnext.log can be also used in ZPT templates:
<tal:block tal:define="log context/@@STXNextLogger;
result python: log.setFilename('logger_filename.log');
result python: log.setName('logger name');">
<tal:block tal:define="result python: log('log this text')" />
<tal:block tal:define="result python: log('log another text', printit=True)" />
<pre tal:replace="structure log/getLoggedTextAsHtml" />
</tal:block>
Instalation
Alternatively, if you are using zc.buildout to manage your project, you can do this:
-
Add stxnext.log to the list of eggs to install, e.g.:
[buildout]
...
eggs =
...
stxnext.log -
If you're using plone.recipe.zope2instance recipe to manage your instance add this lines to install a ZCML slug:
[instance]
recipe = plone.recipe.zope2instance
...
zcml =
...
stxnext.log -
If you're using zc.zope3recipes:application recipe to manage your instance add this lines to install a ZCML slug:
[instance]
recipe = zc.zope3recipes:application
...
site.zcml =
...
<include package="stxnext.log" /> -
Re-run buildout, e.g. with:
$ ./bin/buildout
You can skip the ZCML slug if you are going to explicitly include the package from another package's configure.zcml file.
