Zero configuration JSON logger(r)
Project description
loggerr
Zero configuration JSON logger(r)
from loggerr import Loggerr
logger = Loggerr("warn")
logger.info("Something going as expected", { "host": socket.gethostname() }) # ignored
logger.warn("Something must have gone terribly wrong") # sent
except Exception as e:
logger.error(e, { request: 'this was the request' })
Log level
Create logger instance with a minimal log level
Log levels are (respectively):
- debug
- verbose
- info
- warn
- error
- critical
For example, a logger with log level "warn" will only print logs with level "warn", "error", or "critical".
Arguments
Loggerr class accepts one or two arguments:
- {string} Case insensitive name of minimal log level. defaults to 'info'
- {dictionary} {'Key':'Value'} pairs, optional. Persistent enrichment fields for all log records
logger = Loggerr("warn", { "host": socket.gethostname() })
Logger functions accept one or two arguments:
- {any} Record's "message" field. Traditionally this would be a string or an exception.
- {dictionary} {'Key':'Value'} pairs, optional. Values should be JSON serializable
Synonyms
A couple of function synonyms have been placed to your convenience:
function | will log with level |
---|---|
logger.log(...) |
"info" |
logger.warning(...) |
"warn" |
logger.fatal(...) |
"critical" |
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
loggerr-0.3.0.tar.gz
(2.8 kB
view hashes)