-
Notifications
You must be signed in to change notification settings - Fork 751
Open
Labels
featureRequest for adding a new featureRequest for adding a new feature
Description
I would like to be able to set some global extra's to all log output. This is useful when logs are written to files or terminal from multiple processed running at the same time. This way each line can be connected by PID or some other useful key-value pair. Especially when other modules are also logging and you want to know what is was related to.
Code:
log.set('pid', os.getpid())
log.info("loading account")
account_id = load_account()
log.set('account', account_id)
log.info("computing")
compute(account_id)
log.info("unloading account")
unload(account_id)
log.set('account', None)
log.info("done")
Output:
2025-08-09 07:53:37 [INFO ] [pid=123] loading account
2025-08-09 07:53:37 [INFO ] [pid=123, account=456] computing
2025-08-09 07:53:37 [INFO ] [pid=123, account=456] unloading account
2025-08-09 07:53:37 [INFO ] [pid=123] done
What do you think?
Metadata
Metadata
Assignees
Labels
featureRequest for adding a new featureRequest for adding a new feature