Zaidan common utility classes/functions for the Zaidan system in python.
Classes/functions exported by zaidan
(PyPi package).
A simple logger class that outputs a standardized JSON format.
def __init__(self, name: str, level: str) -> Logger
Create a new logger. Provide a name
for the underlying logging.logger
instance, and a level, for which messages below that level will be ignored.
Accepted levels are (correspond to levels from standard library logging
module):
"debug"
- More verbose, specific state information."info"
- General, normal-operation information."warn"
- Warnings about extreme cases, etc."error"
- Standard errors.
No levels less than "debug" or higher than "error" (critical, etc.) are supported at this time.
def debug(self, message: str, extra: object) -> None
Log an debug
level message. Currently, extra
fields must be provided, along with a message
string.
def info(self, message: str, extra: object) -> None
Log an info
level message. Currently, extra
fields must be provided, along with a message
string.
def warn(self, message: str, extra: object) -> None
Log an warn
level message. Currently, extra
fields must be provided, along with a message
string.
def error(self, message: str, extra: object) -> None
Log an error
level message. Currently, extra
fields must be provided, along with a message
string.
For use with Flask web-applications. Extends the Logger
class, so all log methods are the same.
def __init__(self, app: flask.App, name: str, level: str, suppress_app_logs: bool) -> FlaskLogger
Create a new Flask logger. Required parameters:
app
- The Flask application instance.name
- The name of the application or logger.level
- Log level (seeLogger
).suppress_app_logs
- Set toTrue
to suppress all flask request and werkzug logs.