Skip to main content

An improved SysLogHandler for Python

Project description

Version on Pypi Actions status Docs build status (master) Test coverage (master)

Overview

The syslog2 package provides a syslog2.SysLogHandler class that has some improvements over the standard Python logging.handlers.SysLogHandler class:

  • It supports a new value “local” for the address init parameter that automatically does the right thing for logging to the local system log, without requiring additional syslog demons or the like (other than what is built in to the operating system).

  • When a syslog target is used, it supports the log formats defined in RFC3164 and RFC5424 via a new new optional init parameter format.

  • It supports placing a program name into the log record via a new optional init parameter program.

  • It supports adding a 0x00 Byte at the end of the log message for compatibility with older syslog environments, via a new optional init parameter append_nul that defaults to adding the Byte. This was previously an undocumented class attribute (with the same default).

  • The previously undocumented class attribute facility_names is now officially available for callers to determine valid Syslog facility names and to map them to facility codes.

  • A new class attribute severity_names has been added for callers to determine valid Syslog severity names and to map them to severity codes.

  • The reachability of the targeted system log is verified already during creation of the SysLogHandler object, and not only when logging a message like the standard Python SysLogHandler class does. Issues with the system log are raised through a new syslog2.SysLogTargetError exception.

The new SysLogHandler class is mostly backwards compatible with the standard Python SysLogHandler. There are some incompatibilities, though:

  • The undocumented class attribute append_nul has been removed. This feature is now available as a new optional init parameter append_nul.

  • The undocumented class attributes priority_map and priority_names have been removed or made private.

  • The new SysLogTargetError exception needs to be handled.

Migration to use the new SysLogHandler class is easy as long as you did not use any of the undocumented features:

Old code:

from logging.handlers import SysLogHandler

# ... use it

New code:

from syslog2 import SysLogHandler

# ... use it

Installation

To install the latest released version of the syslog2 package into your active Python environment:

$ pip install syslog2

This will also install any prerequisite Python packages.

For more details and alternative ways to install, see Installation.

Documentation

Change History

Contributing

For information on how to contribute to the syslog2 project, see Contributing.

License

The syslog2 project is provided under the Apache Software License 2.0.

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

syslog2-0.5.0.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

syslog2-0.5.0-py2.py3-none-any.whl (16.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file syslog2-0.5.0.tar.gz.

File metadata

  • Download URL: syslog2-0.5.0.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for syslog2-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d700baa23631e5945e4b9fc1b7aa012ec4d5dbae675bc368e0c98abd9cb87549
MD5 9d8da6986514c2c2857e3971f54bfc93
BLAKE2b-256 dbd06224caf2964b90b06c9e2b309811d9ffd90d90f61cdf88e45df46faab7ea

See more details on using hashes here.

File details

Details for the file syslog2-0.5.0-py2.py3-none-any.whl.

File metadata

  • Download URL: syslog2-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.12

File hashes

Hashes for syslog2-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 daf98cd4f96291194c048bcded2c39b9a84430fad31b76f4e9b997f29d8c8981
MD5 66d157c9d7afde2ae3c48a2d4b0d8458
BLAKE2b-256 66f85619f07e9abb060778704d2925463265db9aaa9e61369ae42e24e3684030

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