diff --git a/cliconfig/__init__.py b/cliconfig/__init__.py index a49433e..cde79bd 100644 --- a/cliconfig/__init__.py +++ b/cliconfig/__init__.py @@ -12,8 +12,8 @@ .. include:: ../DOCUMENTATION.md """ - from cliconfig import ( + _logger, base, cli_parser, config_routines, @@ -22,6 +22,7 @@ processing, tag_routines, ) +from cliconfig._logger import create_logger from cliconfig._version import __version__, __version_tuple__ from cliconfig.base import Config from cliconfig.config_routines import ( @@ -46,9 +47,13 @@ create_processing_value, ) +_CLICONFIG_LOGGER = create_logger() + __all__ = [ "__version__", "__version_tuple__", + "_CLICONFIG_LOGGER", + "_logger", "Config", "DefaultProcessings", "Processing", diff --git a/cliconfig/_logger.py b/cliconfig/_logger.py new file mode 100644 index 0000000..04312d6 --- /dev/null +++ b/cliconfig/_logger.py @@ -0,0 +1,16 @@ +# Copyright (c) 2023 Valentin Goldite. All Rights Reserved. +"""Logging functions for cliconfig.""" +import logging +import sys +from logging import Logger + + +def create_logger() -> Logger: + """Create cliconfig logger.""" + logger = logging.getLogger(__name__) + logger.setLevel(logging.INFO) + handler = logging.StreamHandler(sys.stdout) + formatter = logging.Formatter("%(levelname)s - %(message)s") + handler.setFormatter(formatter) + logger.addHandler(handler) + return logger