Logging in the Python SDK
Track usage and errors in your Expedia Group travel platform SDK
The Expedia Group 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 expediagroup
is the root logger of the SDK, which is a parent to all other loggers used in the SDK, following the standard format expediagroup.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,expediagroup
[logger_root]
handlers=
[logger_expediagroup]
qualname=expediagroup
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
Using the configuration file:
from logging.config import fileConfig
fileConfig("file.cfg")