Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sweep:integration] Remove lock in Logging._createLogRecord #7876

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading