Skip to content

Commit

Permalink
Fix black issue
Browse files Browse the repository at this point in the history
  • Loading branch information
taldcroft committed Mar 8, 2023
1 parent 1e0013e commit 6a0a46e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ska_helpers/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
__all__ = ["basic_logger"]


def basic_logger(name, format="%(asctime)s %(funcName)s: %(message)s", **kwargs):
def basic_logger(
name, format="%(asctime)s %(funcName)s: %(message)s", propagate=False, **kwargs
):
"""Create logger ``name`` using logging.basicConfig.
This is a thin wrapper around logging.basicConfig, except:
Expand All @@ -16,14 +18,20 @@ def basic_logger(name, format="%(asctime)s %(funcName)s: %(message)s", **kwargs)
It will probably work but it is not guaranteed.
This function does nothing if the ``name`` logger already has handlers
configured, unless the keyword argument *force* is set to ``True``.
configured, unless the keyword argument ``force`` is set to ``True``.
It is a convenience method intended to do one-shot creation of a logger.
The default behaviour is to create a StreamHandler which writes to
``sys.stderr``, set a formatter using the format string ``"%(asctime)s
%(funcName)s: %(message)s"``, and add the handler to the ``name`` logger
with a level of WARNING.
By default the created logger will not propagate to parent loggers. This
is to prevent unexpected logging from other packages that set up a root
logger. To propagate to parent loggers, set ``propagate=True``. See
https://docs.python.org/3/howto/logging.html#logging-flow, in particular
how the log level of parent loggers is ignored in message handling.
Example::
# In __init__.py for a package or in any module
Expand Down Expand Up @@ -85,6 +93,8 @@ def basic_logger(name, format="%(asctime)s %(funcName)s: %(message)s", **kwargs)
logger name
format : str
format string for handler
propagate: bool
propagate to parent loggers (default=False)
**kwargs : dict
other keyword arguments for logging.basicConfig
Expand All @@ -111,4 +121,6 @@ def basic_logger(name, format="%(asctime)s %(funcName)s: %(message)s", **kwargs)
finally:
logging.root = root

logger.propagate = propagate

return logger

0 comments on commit 6a0a46e

Please sign in to comment.