mirror of
https://github.com/clearml/clearml
synced 2025-02-07 21:33:25 +00:00
Fix crash in case get_logger() cannot get the file name
This commit is contained in:
parent
0d89497cc9
commit
12d51dae92
@ -108,7 +108,12 @@ def get_logger(path=None, level=None, stream=None, colored=False):
|
|||||||
""" Get a python logging object named using the provided filename and preconfigured with a color-formatted
|
""" Get a python logging object named using the provided filename and preconfigured with a color-formatted
|
||||||
stream handler
|
stream handler
|
||||||
"""
|
"""
|
||||||
|
# noinspection PyBroadException
|
||||||
|
try:
|
||||||
path = path or os.path.abspath((inspect.stack()[1])[1])
|
path = path or os.path.abspath((inspect.stack()[1])[1])
|
||||||
|
except BaseException:
|
||||||
|
# if for some reason we could not find the calling file, use our own
|
||||||
|
path = os.path.abspath(__file__)
|
||||||
root_log = LoggerRoot.get_base_logger(level=default_level, stream=sys.stdout, colored=colored)
|
root_log = LoggerRoot.get_base_logger(level=default_level, stream=sys.stdout, colored=colored)
|
||||||
log = root_log.getChild(Path(path).stem)
|
log = root_log.getChild(Path(path).stem)
|
||||||
if level is not None:
|
if level is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user