logging boilerplate

This commit is contained in:
array-in-a-matrix 2024-08-09 21:35:09 -04:00
parent 8f43a434bd
commit b9969e9596

View file

@ -1,4 +1,4 @@
import std/[strutils, os, json, asyncdispatch, httpclient, with]
import std/[strutils, os, json, asyncdispatch, httpclient, with, logging]
import jester
import checksums/sha3
@ -9,6 +9,34 @@ import ./[database, helpers]
import ./types/[users, files]
import ./routes/[auth, delete, download, upload, update]
const logo = """
█████████ ████ ███
███░░░░░███░░███ ░░░
███ ░░░ ░███ ████ █████████████ ████████ █████ ██████
░███ ░███ ░░███ ░░███░░███░░███ ░░███░░███ ███░░ ███░░███
░███ █████ ░███ ░███ ░███ ░███ ░███ ░███ ░███░░█████ ░███████
░░███ ░░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░░░░███░███░░░
░░█████████ █████ █████ █████░███ █████ ░███████ ██████ ░░██████
░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░ ░░░░░ ░███░░░ ░░░░░░ ░░░░░░
░███
█████
░░░░░
"""
const logFormattingString = "[$date $time] - [$levelname]: "
if cfg.enableLogs:
addHandler newConsoleLogger(fmtStr = logFormattingString)
addHandler newRollingFileLogger("glimpse-logs.log",
fmtStr = logFormattingString)
if cfg.enableErrorLogs:
addHandler newRollingFileLogger("glimpse-errors.log",
fmtStr = logFormattingString, levelThreshold = lvlError)
log(lvlAll, logo)
settings:
bindAddr = cfg.bindAddr
port = Port(cfg.port)