2024-03-03 15:13:01 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
2024-06-17 19:10:50 +02:00
|
|
|
TODO Rename module to console or print
|
|
|
|
|
2024-03-03 15:13:01 +01:00
|
|
|
To use this class, first, instantiate Logger with the name of your module
|
|
|
|
or class, then call the appropriate logging methods on that instance.
|
|
|
|
|
|
|
|
logger = Logger(__name__)
|
|
|
|
logger.debug('This is a debug message')
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
2024-06-13 17:53:53 +02:00
|
|
|
|
2024-03-03 15:13:01 +01:00
|
|
|
class Logger:
|
|
|
|
|
2024-06-13 17:53:53 +02:00
|
|
|
|
2024-03-03 15:13:01 +01:00
|
|
|
def __init__(self, name):
|
|
|
|
self.logger = logging.getLogger(name)
|
2024-05-14 21:39:58 +02:00
|
|
|
self.logger.setLevel(logging.WARNING) # DEBUG
|
2024-03-03 15:13:01 +01:00
|
|
|
|
|
|
|
ch = logging.StreamHandler()
|
2024-03-04 11:16:49 +01:00
|
|
|
ch.setLevel(logging.WARNING)
|
2024-03-03 15:13:01 +01:00
|
|
|
|
2024-03-04 11:16:49 +01:00
|
|
|
formatter = logging.Formatter('[%(asctime)s] %(levelname)s: %(name)s: %(message)s')
|
2024-03-03 15:13:01 +01:00
|
|
|
ch.setFormatter(formatter)
|
|
|
|
|
|
|
|
self.logger.addHandler(ch)
|
|
|
|
|
|
|
|
def critical(self, message):
|
|
|
|
self.logger.critical(message)
|
|
|
|
|
|
|
|
def debug(self, message):
|
|
|
|
self.logger.debug(message)
|
|
|
|
|
|
|
|
def error(self, message):
|
|
|
|
self.logger.error(message)
|
|
|
|
|
|
|
|
def info(self, message):
|
|
|
|
self.logger.info(message)
|
|
|
|
|
|
|
|
def warning(self, message):
|
|
|
|
self.logger.warning(message)
|
2024-03-04 11:16:49 +01:00
|
|
|
|
|
|
|
# def check_difference(function_name, difference):
|
|
|
|
# if difference > 1:
|
2024-06-17 19:10:50 +02:00
|
|
|
# Logger.warning(message)
|
|
|
|
|
|
|
|
|
|
|
|
class Message:
|
|
|
|
|
|
|
|
|
|
|
|
def printer(text):
|
|
|
|
print(text, end='\r')
|