forked from h3h3da/MicroWAF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.py
28 lines (26 loc) · 977 Bytes
/
log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import time
from loguru import logger
from config import LOG_PATH
from sql import insert_log
from pathlib import Path
def log_block(addr, result):
Format = "<green>{time:YYYY-MM-DD HH:mm:ss}</green> | {level} | <level>{message}</level>"
current_path = Path.cwd()
path = Path(current_path, LOG_PATH)
if not path.exists():
path.mkdir(parents=True)
filename = time.strftime("%Y-%m-%d", time.localtime()) + '.log'
logfile = Path(path, filename)
insert_log(str(logfile))
i = logger.add(logfile,
rotation="00:00",
retention="30 days",
level="SUCCESS",
enqueue=True,
format=Format
)
if result["status"] == True:
logger.warning("{type} | {addr} | {url}", addr=addr, type=result["type"], url=result["url"])
elif result["status"] == False:
logger.success("pass | {addr} | {url}", addr=addr, url=result["url"])
logger.remove(i)