MCPcopy Index your code
hub / github.com/tensorlayer/TensorLayer / _get_logger

Function _get_logger

tensorlayer/logging/tl_logging.py:44–87  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43
44def _get_logger():
45 global _logger
46
47 # Use double-checked locking to avoid taking lock unnecessarily.
48 if _logger is not None:
49 return _logger
50
51 _logger_lock.acquire()
52
53 try:
54 if _logger:
55 return _logger
56
57 # Scope the TensorFlow logger to not conflict with users' loggers.
58 logger = _logging.getLogger('tensorlayer')
59
60 # Don't further configure the TensorFlow logger if the root logger is
61 # already configured. This prevents double logging in those cases.
62 if not _logging.getLogger().handlers:
63 # Determine whether we are in an interactive environment
64 # This is only defined in interactive shells.
65 if hasattr(_sys, "ps1"):
66 _interactive = True
67 else:
68 _interactive = _sys.flags.interactive
69
70 # If we are in an interactive environment (like Jupyter), set loglevel
71 # to INFO and pipe the output to stdout.
72 if _interactive:
73 logger.setLevel(INFO)
74 _logging_target = _sys.stdout
75 else:
76 _logging_target = _sys.stderr
77
78 # Add the output handler.
79 _handler = _logging.StreamHandler(_logging_target)
80 _handler.setFormatter(_logging.Formatter('[TL] %(message)s'))
81 logger.addHandler(_handler)
82
83 _logger = logger
84 return _logger
85
86 finally:
87 _logger_lock.release()
88
89
90def log(level, msg, *args, **kwargs):

Callers 9

logFunction · 0.85
debugFunction · 0.85
infoFunction · 0.85
errorFunction · 0.85
fatalFunction · 0.85
warningFunction · 0.85
vlogFunction · 0.85
get_verbosityFunction · 0.85
set_verbosityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…