Skip to main content

WSGI middleware that shows you log messages produced during request handling.

Project description

cipher.logview

WSGI middleware that shows you log messages produced during request handling.

Wraps Dozer and adds a few features:

  • Pretty request timeline for functions decorated with @cipher.logview.timed.

  • Stack formatter shows the value of __traceback_info__ in each stack frame, if a local with that name exists (which is a convention used by zope.exceptions.exceptionformatter).

  • A monkey-patch for zope.browserpage's ViewPageTemplateFile that logs the names of page templates being rendered (enable with monkeypatch=True).

  • A monkey-patch for zope.app.publication's ZopePublication that logs the name of the view class that is being called, and also the representation of and interfaces provided by the content object (enable with monkeypatch=True).

You’ll need this branch of Dozer that contains bugfixes and features not yet included upstream: https://bitbucket.org/mgedmin/dozer

Usage

Add cipher.logview.LogviewMiddleware in your WSGI pipeline.

For example, here’s an excerpt for a PasteDeploy-style paster.ini:

[filter-app:logview]
use = egg:cipher.logview
next = main
loglevel = DEBUG
keep_tracebacks = yes
monkeypatch = yes

# highlighting rules: logview.substring = css-color
logview.sql = #fee
logview.txn = #efe

# traceback highlighting rules: traceback.substring=css-color
traceback.dozer/ = #ddd
traceback.python2.7/ = #ccc
traceback.paste/ = #bbb
traceback.webob/ = #aaa
traceback.weberror/ = #999
traceback.zope/ = #888
traceback.z3c/ = #888
traceback.storm/ = #777
traceback.transaction/ = #666
traceback.ZODB/ = #555
traceback.keas/ = #444
traceback.cipher/ = #840

which lets you optionally enable the middleware from the command line

bin/paster serve paster.ini -n logview

Note: if you want to see debug messages – such as those produced by cipher.logview itself – you will need to make sure the logging level of the root logger is set to DEBUG. If you don’t want debug messages in your log files (and who does?), filter them out by setting the level of each handler. Example paster.ini:

[logging]
keys = root, ...

[logger_root]
handlers = stdout, logfile
level = DEBUG

[handlers]
keys = stdout, logfile, ...

[handler_stdout]
class = StreamHandler
args = (sys.stdout,)
level = INFO
formatter = ...

[handler_logfile]
class = logging.handlers.RotatingFileHandler
args = ('events.log', 'a', 10*1024*1024, 5)
level = INFO
formatter = ...

Changes

1.0.1 (2012-12-07)

  • Handle dynamic subclasses created by <browser:page> and show the real class.

  • Bugfix: sometimes enumerating interfaces of the context could trigger a ForbiddenAttribute exception.

  • Mention logging levels gotcha in README.rst.

1.0.0 (2012-12-05)

  • First public release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cipher.logview-1.0.1.tar.gz (18.7 kB view details)

Uploaded Source

File details

Details for the file cipher.logview-1.0.1.tar.gz.

File metadata

File hashes

Hashes for cipher.logview-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3d23a415e6efe51fcd10b179916d740e611971bca188e2d9bbacd7aae16b301c
MD5 eb5a42c762b5f7554d7370b786483940
BLAKE2b-256 d4af69250ab7d44ab91817d25b2f05678dfa83c94034fd2cc438eaa4b3ad219d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page