Skip to content

stockholmuniversity/su-logging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages