diff --git a/nuclio_sdk/logger.py b/nuclio_sdk/logger.py index 8b2127c..5f632c7 100644 --- a/nuclio_sdk/logger.py +++ b/nuclio_sdk/logger.py @@ -17,10 +17,9 @@ import nuclio_sdk.json_encoder -class JSONFormatter(logging.Formatter): +class RawJSONFormatter(logging.Formatter): def __init__(self): - super(JSONFormatter, self).__init__() - + super(RawJSONFormatter, self).__init__() self._json_encoder = nuclio_sdk.json_encoder.Encoder() def format(self, record): @@ -31,7 +30,15 @@ def format(self, record): 'with': getattr(record, 'with', {}), } - return 'l' + self._json_encoder.encode(record_fields) + return self._json_encoder.encode(record_fields) + + +class JSONFormatter(RawJSONFormatter): + + def format(self, record): + + # on version >= 0.4.0, the `l` prefix is omitted + return 'l' + super(JSONFormatter, self).format(record) class HumanReadableFormatter(logging.Formatter):