Source code for pyquickhelper.loghelper.flog_fake_classes

# -*- coding: utf-8 -*-
"""
Exception specific to this module.


:githublink:`%|py|6`
"""
import logging
import logging.handlers


[docs]class PQHException (Exception): """ custom exception for this file :githublink:`%|py|14` """ pass
[docs]class FlogStatic: """ static variable for the log :githublink:`%|py|22` """
[docs] def __init__(self): """ constructor :githublink:`%|py|27` """ self.store_log_values = dict() self.store_log_values["__log_const"] = "temp_log.txt" self.store_log_values["__log_path"] = "." self.store_log_values["__log_file_name"] = None self.store_log_values["__log_file"] = None self.store_log_values["__log_file_sep"] = "\n" self.store_log_values["__log_display"] = False self.store_log_values["month_date"] = {"jan": 1, "feb": 2, "mar": 3, "apr": 4, "may": 5, "jun": 6, "jul": 7, "aug": 8, "sep": 9, "oct": 10, "nov": 11, "dec": 12}
[docs]class LogFakeFileStream: """ a fake file :githublink:`%|py|43` """
[docs] def __init__(self): """ does nothing :githublink:`%|py|48` """ pass
[docs] def open(self): """ does nothing :githublink:`%|py|54` """ pass
[docs] def write(self, s): """ does nothing :githublink:`%|py|60` """ pass
[docs] def close(self): """ does nothing :githublink:`%|py|66` """ pass
[docs] def flush(self): """ does nothing :githublink:`%|py|72` """ pass
[docs]class LogFileStream: """ log as writing in a file :githublink:`%|py|80` """
[docs] def __init__(self, filename): """ creates a logger :githublink:`%|py|85` """ if filename is None: filename = "temp_log.txt" self.pqlogger = logging.getLogger('logger.pyquickhelper') self.pqlogger.setLevel(logging.INFO) handler = logging.handlers.RotatingFileHandler(filename) self.pqlogger.addHandler(handler)
[docs] def open(self): """ does nothing :githublink:`%|py|96` """ pass
[docs] def write(self, s): """ does nothing :githublink:`%|py|102` """ self.pqlogger.info(s)
[docs] def close(self): """ does nothing :githublink:`%|py|108` """ pass
[docs] def flush(self): """ does nothing :githublink:`%|py|114` """ pass