Logging in the Open World platform SDK for Python
The Open World platform SDK for Python uses the logging module present in Python's standard library, with INFO
as the default level for logs.
Loggers Naming
Logger openworld
is the root logger of the SDK, which is a parent to all other loggers used in the SDK, following the standard format openworld.sdk.core.<package>.<module>
, giving clients the flexibility to configure logging as they desire.
Logging Configuration
By default, logging configuration is handled by the SDK (You will get logs for free, without any setup). In case you want to override the default behaviour, you need to setup a configuration file, following the format and standards specified by the Python Org and Community.
Example:
file.cfg
:
[loggers]
keys=root,openworld
[logger_root]
handlers=
[logger_openworld]
qualname=openworld
level=INFO
handlers=exampleHandler
[handlers]
keys=exampleHandler
[formatters]
keys=exampleFormatter
[formatter_exampleFormatter]
format=[%(asctime)s] %(name)s %(levelname)s: %(message)s
datefmt=%Y-%m-%d %H:%M:%S
[handler_exampleHandler]
class=StreamHandler
level=INFO
formatter=exampleFormatter
Useing the configuration file:
from logging.config import fileConfig
fileConfig("file.cfg")