Skip to content

Commit 2763a35

Browse files
removed unnecessary function
1 parent bf46dfa commit 2763a35

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

redis_json_logger/formatter.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import json
22
import logging
33
import traceback as tb
4-
from .functions import get_current_time_iso
54

65

76
class JSONFormatter(logging.Formatter):
87
required_fields = '__all__'
98
exclude_fields = None
10-
default_datetime_format = '%Y-%m-%d %H:%M:%S'
119

1210
def __init__(self, required_fields=None, exclude_fields=None, datefmt=None):
1311
if required_fields:
@@ -17,7 +15,7 @@ def __init__(self, required_fields=None, exclude_fields=None, datefmt=None):
1715
self.exclude_fields = exclude_fields
1816

1917
if not datefmt:
20-
self.datefmt = self.default_datetime_format
18+
self.datefmt = self.default_time_format
2119
else:
2220
self.datefmt = datefmt
2321

@@ -102,13 +100,12 @@ def convert_to_json_string(self, log_dict):
102100

103101

104102
class LogStashJSONFormatter(JSONFormatter):
105-
default_datetime_format = '%Y-%m-%dT%H:%M:%S'
103+
default_time_format = '%Y-%m-%d %H:%M:%SZ'
106104

107105
def usesTime(self):
108106
return True
109107

110108
def optimize_log_fields(self, python_log_dict):
111109
python_log_dict = super().optimize_log_fields(python_log_dict)
112-
timestamp = python_log_dict.pop('asctime') if 'asctime' in python_log_dict else get_current_time_iso(self.default_datetime_format)
113-
python_log_dict['@timestamp'] = timestamp
110+
python_log_dict['@timestamp'] = python_log_dict.pop('asctime')
114111
return python_log_dict

redis_json_logger/functions.py

-5
This file was deleted.

0 commit comments

Comments
 (0)