Skip to content

Commit

Permalink
Merge pull request DIRACGrid#7876 from DIRACGridBot/cherry-pick-2-639…
Browse files Browse the repository at this point in the history
…8e564f-integration

[sweep:integration] Remove lock in Logging._createLogRecord
  • Loading branch information
fstagni authored Nov 6, 2024
2 parents 0b64038 + a84d5da commit a461a40
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions src/DIRAC/FrameworkSystem/private/standardLogging/Logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,37 +383,31 @@ def _createLogRecord(
:return: boolean representing the result of the log record creation
"""
# exc_info is only for exception to add the stack trace

# extra is a way to add extra attributes to the log record:
# - 'componentname': the system/component name
# - 'varmessage': the variable message
# - 'customname' : the name of the logger for the DIRAC usage: without 'root' and separated with '/'
# as log records, extras attributes are not camel case
extra = {
"componentname": self._componentName,
"varmessage": str(sVarMsg),
"spacer": "" if not sVarMsg else " ",
"customname": self._customName,
}

# lock to prevent a level change after that the log is sent.
self._lockLevel.acquire()
try:
# exc_info is only for exception to add the stack trace

# extra is a way to add extra attributes to the log record:
# - 'componentname': the system/component name
# - 'varmessage': the variable message
# - 'customname' : the name of the logger for the DIRAC usage: without 'root' and separated with '/'
# as log records, extras attributes are not camel case
extra = {
"componentname": self._componentName,
"varmessage": str(sVarMsg),
"spacer": "" if not sVarMsg else " ",
"customname": self._customName,
}

# options such as headers and threadIDs also depend on the logger, we have to add them to extra
extra.update(self._options)
# options such as headers and threadIDs also depend on the logger, we have to add them to extra
extra.update(self._options)

# This typically contains local custom names
if local_context:
extra.update(local_context)
# This typically contains local custom names
if local_context:
extra.update(local_context)

self._logger.log(level, "%s", sMsg, exc_info=exc_info, extra=extra)
# check whether the message is displayed
isSent = LogLevels.getLevelValue(self.getLevel()) <= level
return isSent
finally:
self._lockLevel.release()
self._logger.log(level, "%s", sMsg, exc_info=exc_info, extra=extra)
# check whether the message is displayed
isSent = LogLevels.getLevelValue(self.getLevel()) <= level
return isSent

def showStack(self) -> bool:
"""
Expand Down

0 comments on commit a461a40

Please sign in to comment.