added translations and implemented somewhere but its way too painful so im quitting
This commit is contained in:
parent
5bcd7473f2
commit
30627db730
5 changed files with 147 additions and 58 deletions
25
modules/logger.py
Normal file
25
modules/logger.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
import logging
|
||||
from modules.globalvars import *
|
||||
|
||||
class GooberFormatter(logging.Formatter):
|
||||
def __init__(self, colors: bool = True): # Disable colors for TXT output
|
||||
self.colors = colors
|
||||
|
||||
self._format = f"[ %(levelname)-8s ]: %(message)s {DEBUG} [%(asctime)s.%(msecs)03d] (%(filename)s:%(funcName)s) {RESET}"
|
||||
|
||||
self.FORMATS = {
|
||||
logging.DEBUG: DEBUG + self._format + RESET,
|
||||
logging.INFO: self._format.replace("%(levelname)-8s", f"{GREEN}%(levelname)-8s{RESET}"),
|
||||
logging.WARNING: YELLOW + self._format + RESET,
|
||||
logging.ERROR: RED + self._format + RESET,
|
||||
logging.CRITICAL: PURPLE + self._format + RESET
|
||||
}
|
||||
|
||||
def format(self, record: logging.LogRecord):
|
||||
if self.colors:
|
||||
log_fmt = self.FORMATS.get(record.levelno) # Add colors
|
||||
else:
|
||||
log_fmt = self._format # Just use the default format
|
||||
|
||||
formatter = logging.Formatter(log_fmt, datefmt="%m/%d/%y %H:%M:%S")
|
||||
return formatter.format(record)
|
Loading…
Add table
Add a link
Reference in a new issue