SkygearIO / py-skygear

Skygear Cloud Code Python SDK
https://skygear.io
Other
8 stars 20 forks source link

Implement structural logging with JSON formatter #214

Closed cheungpat closed 6 years ago

cheungpat commented 6 years ago

connects #207

carmenlau commented 6 years ago

@cheungpat For the format of adding tag, it is great. For the extra data handling, now the extra data is added to the payload directly instead of having a extra key. Is it expected? And do skygear-server represent the data in the same way? I am ok with this as we will show user the full payload when expand, just to confirm. If so, let me update the spec:)

My code to log message

log = logging.getLogger(__name__)
log.info("Testing info", extra={
    "key1": "value1",
    "key2": "value2"
})

The output

{
    "key1": "value1",
    "key2": "value2",
    "level": "info",
    "logger": "plugin",
    "msg": "Testing info",
    "tag": "cloud",
    "time": "2018-05-22T23:18:17Z"
}
cheungpat commented 6 years ago

@carmenlau Skygear Server represents the data in the same way. There is more effort to put them in an extra dictionary.