Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think only scripts are meant to call
setup_logger
, see https://nu-radio.github.io/NuRadioMC/NuRadioReco/pages/nur_modules.html#logging and/or double check with @MijnheerD. So I think l.52 and l.11 should be revertedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, individual modules should use the
getLogger
function from the standardlogging
library. Using thesetup_logger()
might work, but I have not tested what the result is.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why wouldn't we use the nice new standardized logging? I have experienced no error so far. And I think this is exactly want we want to do to have a uniform formatting of logger outputs and the status level. Or why would you disagree @MijnheerD @sjoerd-bouma ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new standardized logging. The
setup_logger()
function is only supposed to format the parent logger, not the individual module loggers. Thanks to the inheritance properties of the loggers, the parent logger is the one who will actually report the logs (in the nice format).One potential issue that I just thought of, is that the
setup_logger()
returns a logger which does not further propagate its messages. So I think if you keep l.53 as is, setting a general logging level in the scripts will not work for this module. So I second @sjoerd-bouma suggestion to revert the changes.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sry if I'm slow in understanding how it works. Doesn't it require that the script that imported NuRadioRecoIO initialized a logger with the setup_logger function before the NuRadioRecoIO module initializes its logger?
And I thought if we use the correct naming scheme, i.e., starting the logger name with "NuRadioReco." it will inherit from the correct logger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, the inheritance is taken care of by the naming scheme. But the way the logging is currently set up, is such that the parent logger (i.e. the one with the name "NuRadioReco") is the one who actually handles the log messages. All module loggers simply pass on their messages to the parent logger. And it is the latter that the
setup_logger()
function is supposed to set up.As the inheritance is something that comes from the standard
logging
module itself, there is no need to import anything from our own logging library to initialize the module loggers, they can be called usinglogging.getLogger()
. When using the modules in a script, their loggers will link to the parent logger that is expected to be created at the beginning 1 of the script (using thesetup_logger()
function).Footnotes
From my testing the ordering is actually not important, i.e. the NuRadioReco logger can be created after modules are initialized (though this is not recommended). The modules loggers will find the parent logger as long as it is exists. ↩