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_bind_and_add_level(writer, using_bound):
logger_bound = logger.bind()
logger.add(writer, format="{level.name} {message}")
if using_bound:
logger_bound.level("bar", 15)
else:
logger.level("bar", 15)
logger.log("bar", "root")
logger_bound.log("bar", "bound")
assert writer.read() == "bar root\nbar bound\n"
def test_get_level():
level = ("lvl", 11, "", "[!]")
logger.level(*level)
assert logger.level("lvl") == level
def test_add_invalid_level_name(level_name):
with pytest.raises(TypeError):
logger.level(level_name, 11)
def emit(self, record):
# Get corresponding Loguru level if it exists
try:
level = logger.level(record.levelname).name
except ValueError:
level = record.levelno
# Find caller from where originated the logged message
frame, depth = logging.currentframe(), 2
while frame.f_code.co_filename == logging.__file__:
frame = frame.f_back
depth += 1
logger.bind(name=record.name).opt(depth=depth, exception=record.exc_info).log(
level, record.getMessage()
)
"""Retrieve APD's traffic fatality reports."""
ctx.obj = {**ctx.params}
ctx.auto_envvar_prefix = 'VZ'
# Configure logger.
INITIAL_LOG_LEVEL = logging.WARNING
LOG_FORMAT_COMPACT = "{message}"
LOG_FORMAT_VERBOSE = "{time:YYYY-MM-DDTHH:mm:ssZZ} {name}:{line:<4} {message}"
log_level = max(INITIAL_LOG_LEVEL - verbose * 10, 0)
log_format = LOG_FORMAT_VERBOSE if log_level < logging.INFO else LOG_FORMAT_COMPACT
# Remove any predefined logger.
logger.remove()
# Set the log colors.
logger.level('ERROR', color='')
logger.level('WARNING', color='')
logger.level('SUCCESS', color='')
logger.level('INFO', color='')
logger.level('DEBUG', color='')
logger.level('TRACE', color='')
# Add the logger.
logger.add(sys.stderr, format=log_format, level=log_level, colorize=True)
# Prepare the command.
command = Retrieve(ctx.params, ctx.obj)
command.execute()
# to avoid circular import
from .core.apparatus import Apparatus
from .core.protocol import Protocol
from .components import *
from .core.experiment import Experiment
from . import zoo
from . import plugins
# deactivate logging (see https://loguru.readthedocs.io/en/stable/overview.html#suitable-for-scripts-and-libraries)
from loguru import logger
logger.remove()
logger.level("SUCCESS", icon="✅")
logger.level("ERROR", icon="❌")
logger.level("TRACE", icon="🔍")
# to avoid circular import
from .core.apparatus import Apparatus
from .core.protocol import Protocol
from .components import *
from .core.experiment import Experiment
from . import zoo
from . import plugins
# deactivate logging (see https://loguru.readthedocs.io/en/stable/overview.html#suitable-for-scripts-and-libraries)
from loguru import logger
logger.remove()
logger.level("SUCCESS", icon="✅")
logger.level("ERROR", icon="❌")
logger.level("TRACE", icon="🔍")
from loguru import logger
from tomlkit.toml_document import TOMLDocument
from tomlkit.toml_file import TOMLFile
from .__about__ import __author__, __title__
CONFIG_BASE_PATH = Path(appdirs.user_config_dir(__title__, __author__))
LOG_BASE_PATH = Path(appdirs.user_data_dir(__title__, __author__))
LOG_FORMAT = '[{time:YYYY-MM-DD HH:mm:ss}] {message}'
LOG_DEBUG_FORMAT = LOG_FORMAT
logger.level('NORMAL', no=25, color="")
logger.level('INFO', no=20, color="")
logger.level('ACTION_FAILURE', no=16, color="")
logger.level('ACTION_SUCCESS', no=15, color="")
VERBOSITY_LOG_LEVELS = {
0: 50,
1: 40,
2: 30,
3: 25,
4: 20,
5: 16,
6: 15,
7: 10,
8: 5,
}
def read_config_file(username=None):
config_path = CONFIG_BASE_PATH / (username or '') / 'google-music-scripts.toml'
import appdirs
from loguru import logger
from tomlkit.toml_document import TOMLDocument
from tomlkit.toml_file import TOMLFile
from .__about__ import __author__, __title__
CONFIG_BASE_PATH = Path(appdirs.user_config_dir(__title__, __author__))
LOG_BASE_PATH = Path(appdirs.user_data_dir(__title__, __author__))
LOG_FORMAT = '[{time:YYYY-MM-DD HH:mm:ss}] {message}'
LOG_DEBUG_FORMAT = LOG_FORMAT
logger.level('NORMAL', no=25, color="")
logger.level('INFO', no=20, color="")
logger.level('ACTION_FAILURE', no=16, color="")
logger.level('ACTION_SUCCESS', no=15, color="")
VERBOSITY_LOG_LEVELS = {
0: 50,
1: 40,
2: 30,
3: 25,
4: 20,
5: 16,
6: 15,
7: 10,
8: 5,
}