Skip to content

Commit 566ad69

Browse files
committed
feat (jsonLogger): do not dump in the json all the DIRAC specific formatting options
1 parent 1278d3a commit 566ad69

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/DIRAC/FrameworkSystem/private/standardLogging/Formatter/MicrosecondJsonFormatter.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
import time
2-
from pythonjsonlogger.jsonlogger import JsonFormatter
2+
from pythonjsonlogger.jsonlogger import JsonFormatter, RESERVED_ATTRS
33

44

55
class MicrosecondJsonFormatter(JsonFormatter):
66
"""Standard JSON formater with microsecond precision"""
77

8+
def __init__(self, *args, **kwargs):
9+
"""
10+
Add to the list of attributes we don't want to see
11+
all the DIRAC spefic log formating instructions
12+
"""
13+
if "reserved_attrs" not in kwargs:
14+
kwargs["reserved_attrs"] = RESERVED_ATTRS + (
15+
"spacer",
16+
"headerIsShown",
17+
"timeStampIsShown",
18+
"contextIsShown",
19+
"threadIDIsShown",
20+
"color",
21+
)
22+
super().__init__(*args, **kwargs)
23+
824
def formatTime(self, record, datefmt=None):
925
""":py:meth:`logging.Formatter.formatTime` with microsecond precision by default"""
1026
ct = self.converter(record.created)

0 commit comments

Comments
 (0)