rewritten after codex recommendations
This commit is contained in:
@@ -1,20 +1,27 @@
|
||||
from sys import stderr
|
||||
from Config import *
|
||||
"""Compatibility logging facade."""
|
||||
|
||||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
|
||||
from Config import DEBUG, INFO, LOGFILE
|
||||
|
||||
|
||||
_logger = logging.getLogger("flowers")
|
||||
if not _logger.handlers and (DEBUG or INFO):
|
||||
try:
|
||||
handler = RotatingFileHandler(LOGFILE, maxBytes=1_000_000, backupCount=2)
|
||||
handler.setFormatter(logging.Formatter("%(asctime)s flowers %(levelname)s %(message)s"))
|
||||
_logger.addHandler(handler)
|
||||
_logger.setLevel(logging.DEBUG if DEBUG else logging.INFO)
|
||||
except OSError:
|
||||
_logger.addHandler(logging.NullHandler())
|
||||
|
||||
|
||||
class Log:
|
||||
@staticmethod
|
||||
def info(someString):
|
||||
if INFO:
|
||||
f = open(LOGFILE, "a")
|
||||
f.write( "flower: %s \n" % someString )
|
||||
f.close()
|
||||
if DEBUG:
|
||||
print(someString)
|
||||
def info(message) -> None:
|
||||
_logger.info("%s", message)
|
||||
|
||||
@staticmethod
|
||||
def debug(someString):
|
||||
if DEBUG:
|
||||
f = open(LOGFILE, "a")
|
||||
f.write( "flower: %s \n" % someString )
|
||||
f.close()
|
||||
|
||||
def debug(message) -> None:
|
||||
_logger.debug("%s", message)
|
||||
|
||||
Reference in New Issue
Block a user