Skip to main content

Simple, but fast logging library for Python 3.5+

Project description

This is a simple, but fast logging library. We traded features for speed.

Logwood is only tested with Python 3.5. There are no plans to support older versions.

import logwood
from logwood.handlers.stderr import ColoredStderrHandler

logwood.basic_config(
        level = logwood.INFO,
        handlers = [ColoredStderrHandler()]
)

logger = logwood.get_logger('LoggerName')
logger.info('Just FYI')
logger.warning('Six times seven is {:d}.', 42)

Features

While logwood is very lightweight (see the Compatibility section below) it still gives you a few nice features out of the box:

  • Chunked syslog handler. Splits long messages and writes them to syslog piece by piece. Useful e.g. to work around maximum UDP packet size (logwood.handlers.chunked.ChunkedSysLogHandler).

  • Alternative syslog handler that uses the standard syslog module to emit logs to local syslog. Benchmarks show this to be faster than connecting and writing to a socket directly (logwood.handlers.syslog.SysLogLibHandler).

  • Threaded handler: executes any underlying handler in a separate thread to avoid blocking the main thread (logwood.handlers.threaded.ThreadedHandler).

  • Colored logs on stderr (logwood.handlers.stderr.ColoredStderrHandler).

Compatibility with logging

Logwood API is somewhat similar to the standard logging, but we’ve made a few opinionated design decisions that do not make this a drop-in replacement:

  • Loggers do not form a tree hierarchy. There are no child loggers and no handler or configuration inheritance. We found that such features make the logging module very slow.

  • Logging config cannot be changed after loggers are created, and conversely no loggers may be created until logging is configured. Again, this is to make loggers as simple as possible.

  • While %-style formatting is supported for historical reasons, logwood prefers the more powerful str.format. It tries to guess which formatting style you’re using but defaults to str.format (curly braces). This feature will be removed in a future major release and only str.format will be supported going forward.

logging -> logwood bridge

Call logwood.compat.redirect_standard_logging() to configure the standard logging module to send all messages to logwood for handling. You can use this to run a logwood-based application that nevertheless works with any 3rd-party libraries using logging.

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

logwood-3.0.0.tar.gz (10.9 kB view details)

Uploaded Source

File details

Details for the file logwood-3.0.0.tar.gz.

File metadata

  • Download URL: logwood-3.0.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for logwood-3.0.0.tar.gz
Algorithm Hash digest
SHA256 194d335a420ef85943a73c1b558ee3a308e57a07f5cfaf7378477ccec1633511
MD5 05e325c2bde5e7a5e4f44db3725a12be
BLAKE2b-256 81328127041468b0a0e5249c4a9a25fba963e87a9ece6fe947845c02ba92b423

See more details on using hashes here.

Supported by

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