@@ -50,8 +50,8 @@ def __init__(self):
50
50
for level in levels :
51
51
logging .addLevelName (levels [level ], level )
52
52
53
- # root Logger level is set to NOTICE by default
54
- self ._logger .setLevel (LogLevels .NOTICE )
53
+ # root Logger level is set to INFO by default
54
+ self ._logger .setLevel (LogLevels .INFO )
55
55
56
56
# initialization of the UTC time
57
57
# Actually, time.gmtime is equal to UTC time: it has its DST flag to 0 which means there is no clock advance
@@ -116,14 +116,45 @@ def initialize(self, systemName, cfgPath, forceInit=False):
116
116
for handler in handlersToRemove :
117
117
self ._logger .removeHandler (handler )
118
118
119
- levelName = gConfig . getValue ( f" { cfgPath } /LogLevel" , None )
119
+ levelName = self . __getLogLevelFromCFG ( cfgPath )
120
120
if levelName is not None :
121
121
self .setLevel (levelName )
122
122
123
123
LoggingRoot .__configuredLogging = True
124
124
finally :
125
125
self ._lockConfig .release ()
126
126
127
+ def __getLogLevelFromCFG (self , cfgPath ):
128
+ """
129
+ Get the logging level from the cfg, following this order:
130
+
131
+ * cfgPath/LogLevel
132
+ * Operations/<setup/vo>/Logging/Default<Agents/Services>LogLevel
133
+ * Operations/<setup/vo>/Logging/DefaultLogLevel
134
+
135
+ :param str cfgPath: configuration path
136
+ """
137
+ # We have to put the import line here to avoid a dependancy loop
138
+ from DIRAC .ConfigurationSystem .Client .Helpers .Operations import Operations
139
+ from DIRAC import gConfig
140
+
141
+ # Search desired log level in the component
142
+ logLevel = gConfig .getValue (f"{ cfgPath } /LogLevel" )
143
+ if not logLevel :
144
+ # get the second last string representing the component type in the configuration
145
+ # example : 'Agents', 'Services'
146
+ component = cfgPath .split ("/" )[- 2 ]
147
+
148
+ operation = Operations ()
149
+ # Search desired logLevel in the operation section according to the
150
+ # component type
151
+ logLevel = operation .getValue (f"Logging/Default{ component } LogLevel" )
152
+ if not logLevel :
153
+ # Search desired logLevel in the operation section
154
+ logLevel = operation .getValue ("Logging/DefaultLogLevel" )
155
+
156
+ return logLevel
157
+
127
158
def __getBackendsFromCFG (self , cfgPath ):
128
159
"""
129
160
Get backends from the configuration and register them in LoggingRoot.
@@ -135,14 +166,14 @@ def __getBackendsFromCFG(self, cfgPath):
135
166
from DIRAC .ConfigurationSystem .Client .Helpers .Operations import Operations
136
167
from DIRAC import gConfig
137
168
138
- # get the second last string representing the component type in the configuration
139
- # example : 'Agents', 'Services'
140
- component = cfgPath .split ("/" )[- 2 ]
141
- operation = Operations ()
142
-
143
169
# Search desired backends in the component
144
170
backends = gConfig .getValue (f"{ cfgPath } /LogBackends" , [])
145
171
if not backends :
172
+ # get the second last string representing the component type in the configuration
173
+ # example : 'Agents', 'Services'
174
+ component = cfgPath .split ("/" )[- 2 ]
175
+
176
+ operation = Operations ()
146
177
# Search desired backends in the operation section according to the
147
178
# component type
148
179
backends = operation .getValue (f"Logging/Default{ component } Backends" , [])
0 commit comments