mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-04 21:29:12 +00:00
Move Custom Formatter class for logger to util.helper module from main.py
This commit is contained in:
26
src/main.py
26
src/main.py
@@ -24,6 +24,7 @@ from src.routers.api_beta import api_beta
|
||||
from src.routers.web_client import web_client
|
||||
from src.utils import constants, state
|
||||
from src.utils.cli import cli
|
||||
from src.utils.helpers import CustomFormatter
|
||||
from src.interface.desktop.main_window import MainWindow
|
||||
from src.interface.desktop.system_tray import create_system_tray
|
||||
|
||||
@@ -38,31 +39,6 @@ app.include_router(web_client)
|
||||
logger = logging.getLogger('src')
|
||||
|
||||
|
||||
class CustomFormatter(logging.Formatter):
|
||||
|
||||
blue = "\x1b[1;34m"
|
||||
green = "\x1b[1;32m"
|
||||
grey = "\x1b[38;20m"
|
||||
yellow = "\x1b[33;20m"
|
||||
red = "\x1b[31;20m"
|
||||
bold_red = "\x1b[31;1m"
|
||||
reset = "\x1b[0m"
|
||||
format_str = "%(levelname)s: %(asctime)s: %(name)s | %(message)s"
|
||||
|
||||
FORMATS = {
|
||||
logging.DEBUG: blue + format_str + reset,
|
||||
logging.INFO: green + format_str + reset,
|
||||
logging.WARNING: yellow + format_str + reset,
|
||||
logging.ERROR: red + format_str + reset,
|
||||
logging.CRITICAL: bold_red + format_str + reset
|
||||
}
|
||||
|
||||
def format(self, record):
|
||||
log_fmt = self.FORMATS.get(record.levelno)
|
||||
formatter = logging.Formatter(log_fmt)
|
||||
return formatter.format(record)
|
||||
|
||||
|
||||
def run():
|
||||
# Turn Tokenizers Parallelism Off. App does not support it.
|
||||
os.environ["TOKENIZERS_PARALLELISM"] = 'false'
|
||||
|
||||
Reference in New Issue
Block a user