Skip to content

Log.set_error_level is setting an attribute in the error function (function can be deleted?) #2514

@kinow

Description

@kinow

Description

Another one found writing tests for #2475 , reviewing the code.

At the end of the set_error_level function we set .level of Log.error to the given level argument.

autosubmit/log/log.py

Lines 289 to 300 in 1bed696

@staticmethod
def set_error_level(level):
"""
Sets log level for logging to console. Every output of level equal or higher to parameter level will be
printed on console
:param level: new level for console
:return: None
"""
if type(level) is str:
level = getattr(Log, level)
Log.error.level = level

Note, however, that error is a function of Log, not an object.

autosubmit/log/log.py

Lines 360 to 368 in 1bed696

def error(msg, *args):
"""
Sends errors to the log. It will be shown in red in the console.
:param msg: message to show
:param args: arguments for message formatting (it will be done using format() method on str)
"""
msg = Log._verify_args_message(msg, *args)
Log.log.log(Log.ERROR, msg)

Sometimes you do that like in context managers, of custom decorators. But it doesn't look like i was the intention here. The function appears to be a copy-and-paste of set_console_level, so it could be that at some point it worked, or maybe it was accidentally duplicated.

  • Autosubmit version: 4.1.15+, master

Reproducible Example

See screenshots.

Expected Behaviour

No idea, I think the function can be deleted, I couldn't find where it's used besides the test I wrote.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions