Skip to content

Commit efa053e

Browse files
committed
feat: gLogger enables logs from ext libs only if level is debug and DIRAC not used as a lib
1 parent 643c0bd commit efa053e

File tree

8 files changed

+13
-16
lines changed

8 files changed

+13
-16
lines changed

docs/source/AdministratorGuide/Resources/messagequeues.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ like described in :ref:`development_use_mq`, for example::
9595
message = result['Value']
9696

9797

98-
In order not to spam the logs, the log output of Stomp is always silence, unless the environment variable `DIRAC_DEBUG_STOMP` is set to any value.
99-
100-
10198
Message Queue nomenclature in DIRAC
10299
-----------------------------------
103100

docs/source/AdministratorGuide/ServerInstallations/environment_variable_configuration.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ DIRAC_DEBUG_DENCODE_CALLSTACK
1414
DIRAC_DEBUG_M2CRYPTO
1515
If ``true`` or ``yes``, print a lot of SSL debug output
1616

17-
DIRAC_DEBUG_STOMP
18-
If set, the stomp library will print out debug information
19-
2017
DIRAC_DEPRECATED_FAIL
2118
If set, the use of functions or objects that are marked ``@deprecated`` will fail. Useful for example in continuous
2219
integration tests against future versions of DIRAC

src/DIRAC/ConfigurationSystem/Client/LocalConfiguration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ def initialize(self, *, returnErrors=False):
311311

312312
def __initLogger(self, componentName, logSection, forceInit=False):
313313
gLogger.initialize(componentName, logSection, forceInit=forceInit)
314+
gLogger.disableLogsFromExternalLibs()
314315

315316
if self.__debugMode == 1:
316317
gLogger.setLevel("VERBOSE")
@@ -320,6 +321,7 @@ def __initLogger(self, componentName, logSection, forceInit=False):
320321
elif self.__debugMode >= 3:
321322
gLogger.setLevel("DEBUG")
322323
gLogger.showHeaders(True)
324+
gLogger.enableLogsFromExternalLibs()
323325

324326
def loadUserData(self):
325327
"""

src/DIRAC/FrameworkSystem/private/standardLogging/LoggingRoot.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ def __init__(self):
3636
- update the format according to the command line argument
3737
3838
"""
39-
# initialize the root logger, which turns out to be a child of root
39+
# initialize the DIRAC root logger, which turns out to be a child of root
40+
# it is strongly advised to use a logger with a unique and identifiable name:
41+
# https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library
4042
super().__init__(name="dirac")
4143

4244
# this line removes some useless information from log records and improves the performances
@@ -259,12 +261,20 @@ def __configureLevel(self):
259261
def enableLogsFromExternalLibs(self):
260262
"""
261263
Enable the display of the logs coming from external libraries
264+
265+
.. warning::
266+
267+
This method should only be used for debugging purposes.
262268
"""
263269
self.__enableLogsFromExternalLibs()
264270

265271
def disableLogsFromExternalLibs(self):
266272
"""
267273
Disable the display of the logs coming from external libraries
274+
275+
.. warning::
276+
277+
This method should only be used for debugging purposes.
268278
"""
269279
self.__enableLogsFromExternalLibs(False)
270280

src/DIRAC/Resources/Computing/BOINCComputingElement.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ def createClient(self):
4848
try:
4949
from suds.client import Client
5050

51-
if self.log.getLevel() == "DEBUG":
52-
self.log.enableLogsFromExternalLibs()
5351
self.BOINCClient = Client(self.wsdl)
5452
except Exception as x:
5553
self.log.error("Creation of the soap client failed", f"{str(x)}")

src/DIRAC/Resources/MessageQueue/StompMQConnector.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ def __init__(self, parameters=None):
4343
super().__init__(parameters=parameters)
4444
self.connection = None
4545

46-
if "DIRAC_DEBUG_STOMP" in os.environ:
47-
gLogger.enableLogsFromExternalLibs()
48-
4946
def setupConnection(self, parameters=None):
5047
"""
5148
Establishes a new connection to a Stomp server, e.g. RabbitMQ

src/DIRAC/Resources/Storage/GFAL2_StorageBase.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ def __init__(self, storageName: str, parameters: dict[str, str]):
135135

136136
dlevel = self.log.getLevel()
137137
if dlevel == "DEBUG":
138-
gLogger.enableLogsFromExternalLibs()
139138
gfal2.set_verbose(gfal2.verbose_level.trace)
140139

141140
# # gfal2 API

src/DIRAC/WorkloadManagementSystem/scripts/dirac_wms_cpu_normalization.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ def main():
4949

5050
gLogger.info("Computing benchmark measurements on", "%d processor(s)..." % numberOfProcessors)
5151

52-
# we want to get the logs coming from db12
53-
gLogger.enableLogsFromExternalLibs()
54-
5552
# multiprocessor allocations generally have a CPU Power lower than single core one.
5653
# in order to avoid having wrong estimations, we run multiple copies of the benchmark simultaneously
5754
result = multiple_dirac_benchmark(numberOfProcessors)

0 commit comments

Comments
 (0)