Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_log_before_disable_f_globals_name_absent(writer, f_globals_name_absent):
logger.add(writer, format="{message}")
logger.enable(None)
logger.debug("yes")
logger.disable(None)
logger.debug("nope")
result = writer.read()
assert result == "yes\n"
def test_f_globals_name_absent_with_others(writer, f_globals_name_absent):
logger.add(writer, format="{message}")
logger.info("1")
logger.enable(None)
logger.disable("foobar")
logger.enable("foo.bar")
logger.disable(None)
logger.info("2")
logger.enable("foobar")
logger.enable(None)
logger.info("3")
assert writer.read() == "1\n3\n"
n = lambda: len(logger._core.activation_list)
assert n() == 0
logger.enable("")
assert n() == 0
logger.disable("")
assert n() == 1
logger.enable("foo")
assert n() == 2
logger.enable("foo.bar")
assert n() == 2
logger.disable("foo")
assert n() == 1
logger.disable("foo.bar")
assert n() == 1
logger.enable("foo.bar")
assert n() == 2
logger.disable("foo.bar.baz")
assert n() == 3
logger.disable("foo.baz")
assert n() == 3
logger.disable("foo.baz.bar")
assert n() == 3
logger.enable("foo.baz.bar")
assert n() == 4
logger.enable("")
assert n() == 0
logger.enable,
logger.configure,
logger.parse,
logger.exception,
],
)
def test_pickling_no_error(method):
pickled = pickle.dumps(method)
unpickled = pickle.loads(pickled)
assert unpickled
def enable_logger(sink=sys.stderr, level="WARNING"):
"""
Enable the logging of messages.
Configure the ``logger`` variable imported from ``loguru``.
Args:
sink (file): An opened file pointer, or stream handler. Default to standard error.
level (str): The log level to use. Possible values are TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL.
Default to WARNING.
"""
logger.remove()
logger.configure(handlers=[{"sink": sink, "level": level}])
logger.enable("aria2p")
from .lmar import lmar
from .lmgraph import lmgraph
from .lmlpb import lmlpb
from .lmlsb import lmlsb
from .lmpatch import lmpatch
__all__ = ["galconvert", "lmar", "lmbmp", "lmgraph", "lmlpb", "lmlsb", "lmpatch"]
logger.remove()
if os.name == "nt":
sys.stdout.reconfigure(encoding="utf-8", errors="backslashreplace")
logger.add(sys.stderr, level="WARNING")
logger.enable("livemaker")
choices=['Spotify', 'Music'], help='Music application')
parser.add_argument('--minimal', default=False,
action='store_true', help='Remove title and artists')
parser.add_argument('--bg', default='51,204,153', type=str,
help='Background color in RGB')
parser.add_argument('--fs', default=12, type=int,
help='Font size')
parser.add_argument('--fc', default='255,255,255',
type=str, help='Font color in RGB')
parser.add_argument('--traditional', default=False, action='store_true', help='Convert simplified chinese to traditional chinese')
parser.add_argument('--verbose', action='store_true',
help='Turn on debug mode', default=False)
args = parser.parse_args()
if args.verbose:
logger.enable("touchbar_lyric")
logger.enable("__main__")
else:
logger.disable("touchbar_lyric")
logger.disable("__main__")
logger.debug(args)
main(
app=args.app,
minimal=args.minimal,
background_color=args.bg,
font_size=args.fs,
font_color=args.fc,
traditional=args.traditional)
logger.__class__.diagnostic = diagnostic
def showwarning(message, cls, source, lineno, *args):
logger.warning(
'{warning}: {message} ({source}:{lineno})',
message=message,
warning=cls.__name__,
source=source,
lineno=lineno
)
warnings.showwarning = showwarning
if runtime_state.proc_rank == 0:
logger.enable('veros')
else:
logger.disable('veros')
return logger.configure(**config)
def configure_logging(
modifier=0,
*,
username=None,
debug=False,
log_to_stdout=True,
log_to_file=False
):
logger.remove()
if debug:
logger.enable('audio_metadata')
logger.enable('google_music')
logger.enable('google_music-proto')
logger.enable('google_music_utils')
verbosity = 3 + modifier
if verbosity < 0:
verbosity = 0
elif verbosity > 8:
verbosity = 8
log_level = VERBOSITY_LOG_LEVELS[verbosity]
if log_to_stdout:
logger.add(
sys.stdout,
level=log_level,
format=LOG_FORMAT,
backtrace=False