Skip to main content

Logging for Stockholm University

Project description

Logging for Stockholm University

Easy to use logging for Stockholm University.

Usage

Syslog

For normal usage which logs to syslog:

from su.logging import logging

logger = logging.getLogger("myapp")
logger.warning("My WARNING message")

Console

For easier developing you can also switch to console logging:

from su.logging import console, logging

logger = logging.getLogger("myapp")
logger.warning("My WARNING message")

Structured logging

We use logstash_formatter's LogstashFormatterV1 and remove some unused/unnecesary fields.

Depend on su-logging[structured] in e.g. your requirements.txt and then:

from su.logging import logging, structured

logger = logging.getLogger("myapp")
logger.warning("User logged in", extra={"user": "simlu"})

try:
    raise Exception("User performed illegal activity")
except Exception as e:
    logger.exception(e, extra={"user": "simlu"})

Container usage

In Containers, which usually adhere to the 12 factor apps manifesto, you usually log to STDOUT and let your container engine deal with them.

from su.logging import console, logging, structured

logger = logging.getLogger("myapp")
logger.warning("My WARNING message")

TODO

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

su-logging-1.0.0.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

su_logging-1.0.0-py3-none-any.whl (3.0 kB view hashes)

Uploaded Python 3

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