Skip to content

Commit 1278d3a

Browse files
committed
fix: stdoutJson logger prints all needed fields
1 parent 4836a93 commit 1278d3a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/DIRAC/Resources/LogBackends/StdoutJsonBackend.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@
88
from DIRAC.FrameworkSystem.private.standardLogging.Formatter.MicrosecondJsonFormatter import MicrosecondJsonFormatter
99

1010

11+
# These are the standard logging fields that we want to see
12+
# in the json. All the non default are printed anyway
13+
DEFAULT_FMT = "%(levelname)s %(message)s %(asctime)s"
14+
15+
1116
class StdoutJsonBackend(AbstractBackend):
1217
"""
1318
This just spits out the log on stdout in a json format.
1419
"""
1520

1621
def __init__(self, backendParams=None, backendFilters=None):
22+
# The `Format` parameter is passed as `fmt` to MicrosecondJsonFormatter
23+
# which uses it to know which "standard" fields to keep in the
24+
# json output. So we need these
25+
if not backendParams:
26+
backendParams = {}
27+
backendParams.setdefault("Format", DEFAULT_FMT)
28+
1729
super().__init__(logging.StreamHandler, MicrosecondJsonFormatter, backendParams, backendFilters)
1830

1931
def _setHandlerParameters(self, backendParams=None):

0 commit comments

Comments
 (0)