Commit 42b9eb48 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[log] Removed unused code

parent d887fb19
......@@ -3,74 +3,8 @@
"""Sets-up logging, centrally for beat cmdline
import sys
import logging
# get the default root logger of Beat
_logger = logging.getLogger('beat')
# by default, warning and error messages should be written to sys.stderr
_warn_err = logging.StreamHandler(sys.stderr)
# debug and info messages are written to sys.stdout
class _InfoFilter:
def filter(self, record):
return record.levelno <= logging.INFO
_debug_info = logging.StreamHandler(sys.stdout)
# helper functions to instantiate and set-up logging
def setup(logger_name,
format="%(name)s@%(asctime)s -- %(levelname)s: %(message)s"):
"""This function returns a logger object that is set up to perform logging
using beat loggers.
logger_name : str
The name of the module to generate logs for
format : :obj:`str`, optional
The format of the logs, see :py:class:`logging.LogRecord` for more
details. By default, the log contains the logger name, the log time, the
log level and the massage.
logger : :py:class:`logging.Logger`
The logger configured for logging. The same logger can be retrieved using
the :py:func:`logging.getLogger` function.
# generate new logger object
logger = logging.getLogger(logger_name)
# add log the handlers if not yet done
if not logger_name.startswith("beat") and not logger.handlers:
# this formats the logger to print the desired information
formatter = logging.Formatter(format)
# we have to set the formatter to all handlers registered in the current
# logger
for handler in logger.handlers:
# set the same formatter for beat loggers
for handler in _logger.handlers:
return logger
def set_verbosity_level(logger, level):
"""Sets the log level for the given logger.
......@@ -88,8 +22,8 @@ def set_verbosity_level(logger, level):
if level not in range(0, 4):
raise ValueError(
"The verbosity level %d does not exist. Please reduce the number of "
"'--verbose' parameters in your command line" % level
"The verbosity level %d does not exist. Please reduce the number "
"of '--verbose' parameters in your command line" % level
# set up the verbosity level of the logging system
log_level = {
......@@ -103,7 +37,3 @@ def set_verbosity_level(logger, level):
if isinstance(logger, str):
logger = logging.getLogger(logger)
# set the same log level for the beat logger
__all__ = [_ for _ in dir() if not _.startswith('_')]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment