예제 #1
0
def configure_logging(app):
    """
    Sets up application wide logging.

    :param app:
    """
    handler = RotatingFileHandler(app.config.get("LOG_FILE", "lemur.log"),
                                  maxBytes=10000000,
                                  backupCount=100)

    handler.setFormatter(
        Formatter("%(asctime)s %(levelname)s: %(message)s "
                  "[in %(pathname)s:%(lineno)d]"))

    if app.config.get("LOG_JSON", False):
        handler.setFormatter(
            logmatic.JsonFormatter(extra={"hostname": socket.gethostname()}))

    handler.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
    app.logger.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
    app.logger.addHandler(handler)

    stream_handler = StreamHandler()
    stream_handler.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
    app.logger.addHandler(stream_handler)

    if app.config.get("DEBUG_DUMP", False):
        activate_debug_dump()
예제 #2
0
파일: factory.py 프로젝트: harmw/lemur
def configure_logging(app):
    """
    Sets up application wide logging.

    :param app:
    """
    handler = RotatingFileHandler(app.config.get('LOG_FILE', 'lemur.log'), maxBytes=10000000, backupCount=100)

    handler.setFormatter(Formatter(
        '%(asctime)s %(levelname)s: %(message)s '
        '[in %(pathname)s:%(lineno)d]'
    ))

    handler.setLevel(app.config.get('LOG_LEVEL', 'DEBUG'))
    app.logger.setLevel(app.config.get('LOG_LEVEL', 'DEBUG'))
    app.logger.addHandler(handler)

    stream_handler = StreamHandler()
    stream_handler.setLevel(app.config.get('LOG_LEVEL', 'DEBUG'))
    app.logger.addHandler(stream_handler)

    if app.config.get('DEBUG_DUMP', False):
        activate_debug_dump()
예제 #3
0
파일: factory.py 프로젝트: seils/lemur
def configure_logging(app):
    """
    Sets up application wide logging.

    :param app:
    """
    handler = RotatingFileHandler(app.config.get('LOG_FILE', 'lemur.log'), maxBytes=10000000, backupCount=100)

    handler.setFormatter(Formatter(
        '%(asctime)s %(levelname)s: %(message)s '
        '[in %(pathname)s:%(lineno)d]'
    ))

    handler.setLevel(app.config.get('LOG_LEVEL', 'DEBUG'))
    app.logger.setLevel(app.config.get('LOG_LEVEL', 'DEBUG'))
    app.logger.addHandler(handler)

    stream_handler = StreamHandler()
    stream_handler.setLevel(app.config.get('LOG_LEVEL', 'DEBUG'))
    app.logger.addHandler(stream_handler)

    if app.config.get('DEBUG_DUMP', False):
        activate_debug_dump()
예제 #4
0
파일: factory.py 프로젝트: vsnine/lemur
def configure_logging(app):
    """
    Sets up application wide logging.

    :param app:
    """
    logfile = app.config.get("LOG_FILE", "lemur.log")
    # if the log file is a character special device file (ie. stdout/stderr),
    # file rotation will not work and must be disabled.
    disable_file_rotation = os.path.exists(logfile) and stat.S_ISCHR(
        os.stat(logfile).st_mode)
    if disable_file_rotation:
        handler = StreamHandler(open(logfile, 'a'))
    else:
        handler = RotatingFileHandler(logfile,
                                      maxBytes=10000000,
                                      backupCount=100)

    handler.setFormatter(
        Formatter("%(asctime)s %(levelname)s: %(message)s "
                  "[in %(pathname)s:%(lineno)d]"))

    if app.config.get("LOG_JSON", False):
        handler.setFormatter(
            logmatic.JsonFormatter(extra={"hostname": socket.gethostname()}))

    handler.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
    app.logger.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
    app.logger.addHandler(handler)

    stream_handler = StreamHandler()
    stream_handler.setLevel(app.config.get("LOG_LEVEL", "DEBUG"))
    app.logger.addHandler(stream_handler)

    if app.config.get("DEBUG_DUMP", False):
        activate_debug_dump()