Package to support logging standards at uniplaces (www.uniplaces.com). Used to enforce uniplaces log standards and respect uniplaces logging interface.
Log level respect RFC5424 https://tools.ietf.org/html/rfc5424
Add tests and travis.
This package needs python3 and has a dependency over logbook.
$ pip3 install unipy_logger
unipy*logger is fetching some evironment variables that must be set on runtime or exported in order for the logger to find them. These are APPID, ENV and GITHASH used to populate respectively app-id, env, git-hash. In order to add context fields that will be outputed in the resulting log json use addContextFields (receiving a dictionary) or *addContextField* (receiving a key value pair).
from unipy_logger import Logger
CONTEXT_FIELDS = {
"foo": "bar",
"lorem": "ipsum",
"value": 10
}
Logger(sys.stdout, "DEBUG")
Logger.builder().addContextFields(CONTEXT_FIELDS).info("my first log")
# output
# {
# "message": "my first log",
# "app-id": "unipy_logger",
# "git-hash": "28390e1f54d54b5189f5ec771860bc569e8ec507",
# "time": "2018-01-30T15:14:45.43Z",
# "env": dev,
# "level_name": "INFO",
# "level: 6,
# "foo": "bar",
# "lorem": "ipsum",
# "value": 10
# }
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Made with ❤️ at uniplaces
This project is licensed under the MIT License - see the LICENSE.md file for details