Commit f4478b9b authored by Cyril Roelandt's avatar Cyril Roelandt
Browse files

Add missing file.

parent 55d50672
......@@ -3,6 +3,9 @@ All notable changes to this project will be documented in this file.
Based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [Unreleased]
- upt.log: Add missing file
## [0.4] - 2018-03-20
### Added
- upt package: Add the '--output' option
......
# Copyright 2018 Cyril Roelandt
#
# Licensed under the 3-clause BSD license. See the LICENSE file.
import logging
import sys
class MaxLevelFilter(logging.Filter):
def __init__(self, max_level):
self.max_level = max_level
super().__init__()
def filter(self, record):
return record.levelno < self.max_level
def create_logger(log_level):
logger = logging.getLogger('upt')
logger.setLevel(log_level or logging.INFO)
stdout_handler = logging.StreamHandler(sys.stdout)
stdout_handler.addFilter(MaxLevelFilter(logging.ERROR))
logger.addHandler(stdout_handler)
stderr_handler = logging.StreamHandler(sys.stderr)
stderr_handler.setLevel(logging.ERROR)
logger.addHandler(stderr_handler)
return logger
def logger_set_formatter(logger, name):
formatter = logging.Formatter(f'[%(levelname)-8s] [{name}] %(message)s')
for handler in logger.handlers:
handler.setFormatter(formatter)
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