forked from phoenix/litellm-mirror
fix(_logging.py): add loglevel and timestamp to json logs
Fixes https://github.com/BerriAI/litellm/issues/4248
This commit is contained in:
parent
4f32bca8d9
commit
4cddd1eb31
3 changed files with 18 additions and 7 deletions
|
@ -1,6 +1,8 @@
|
|||
import logging, os, json
|
||||
from logging import Formatter
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import traceback
|
||||
from logging import Formatter
|
||||
|
||||
set_verbose = False
|
||||
|
||||
|
@ -21,8 +23,12 @@ class JsonFormatter(Formatter):
|
|||
super(JsonFormatter, self).__init__()
|
||||
|
||||
def format(self, record):
|
||||
json_record = {}
|
||||
json_record["message"] = record.getMessage()
|
||||
json_record = {
|
||||
"message": record.getMessage(),
|
||||
"level": record.levelname,
|
||||
"timestamp": self.formatTime(record, self.datefmt),
|
||||
}
|
||||
|
||||
return json.dumps(json_record)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue