-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Under the create_frame function, we are converting 'levelno' field to 'severity' by dividing by 10 and then converting to integer, as in below;
frame['severity'] = int(r['levelno'] / 10)
in doing so we are losing custom log levels created by the user. For example I have additional 2 log levels that have levelno of 25 and 35. These are converted to 2 and 3 respectively. This makes it impossible to query using something like severity>25 when I want to get the events that have levelno greater than 25.
I guess we cannot do something like below, which will break compatibailty who are using severity as is
frame['severity'] = r['levelno']
so maybe we can add a field?
frame['level_no'] = r['levelno']
this will enable to query with finer granularity.
I did not want to create a PR because I thought there must be a reason why this has not been already added.
Or even better idea; why not pass a dict which has the python-to-logtail mappings to the handler and frame can be created using this mapping? something like below;
# frame.py
def create_frame(record, message, context, include_extra_attributes=False, mapping: dict = None):
... # omitted code
if mapping:
for k, v in mapping.items():
frame[v] = getattr(record, k)
... # omitted code
return frame