Skip to content

Commit

Permalink
log
Browse files Browse the repository at this point in the history
  • Loading branch information
Carreau committed Oct 29, 2024
1 parent 7d1390e commit ed17b66
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/python/pyflyby/_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,20 @@ def wrapped_func():
proxy.__dict__ = prev


import json_log_formatter


class VV(json_log_formatter.VerboseJSONFormatter):
def json_record(self, message, extra, record):
extra["msg"] = record.msg
return super().json_record(message, extra, record)


formatter = VV()

json_handler = logging.StreamHandler()
json_handler.setFormatter(formatter)

class PyflybyLogger(Logger):

_LEVELS = dict( (k, getattr(logging, k))
Expand All @@ -165,7 +179,8 @@ class PyflybyLogger(Logger):
def __init__(self, name, level):
Logger.__init__(self, name)
handler = _PyflybyHandler()
self.addHandler(handler)
# self.addHandler(handler)
self.addHandler(json_handler)
self.set_level(level)

def set_level(self, level):
Expand Down

0 comments on commit ed17b66

Please sign in to comment.