Update public source
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime, timezone
|
import time
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
@@ -9,12 +9,7 @@ LOGGER_NAME = "cracklab.client"
|
|||||||
|
|
||||||
|
|
||||||
class UTCFormatter(logging.Formatter):
|
class UTCFormatter(logging.Formatter):
|
||||||
converter = staticmethod(
|
converter = staticmethod(time.gmtime)
|
||||||
lambda timestamp: datetime.fromtimestamp(
|
|
||||||
timestamp,
|
|
||||||
tz=timezone.utc,
|
|
||||||
).timetuple()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _configure(
|
def _configure(
|
||||||
@@ -37,7 +32,7 @@ def _configure(
|
|||||||
)
|
)
|
||||||
handler.setFormatter(
|
handler.setFormatter(
|
||||||
UTCFormatter(
|
UTCFormatter(
|
||||||
"%(asctime)sZ %(levelname)s %(message)s",
|
"%(asctime)s.%(msecs)03dZ [%(levelname)s] %(name)s: %(message)s",
|
||||||
datefmt="%Y-%m-%dT%H:%M:%S",
|
datefmt="%Y-%m-%dT%H:%M:%S",
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
+8
-2
@@ -68,6 +68,11 @@ from sudo import SudoChecker
|
|||||||
from config import Config
|
from config import Config
|
||||||
from gps_test import GPSTestService
|
from gps_test import GPSTestService
|
||||||
from gui.timezones import get_timezone_options
|
from gui.timezones import get_timezone_options
|
||||||
|
from logging_config import (
|
||||||
|
LOG_DATE_FORMAT,
|
||||||
|
LOG_FORMAT,
|
||||||
|
UTCFormatter,
|
||||||
|
)
|
||||||
|
|
||||||
app = Flask(
|
app = Flask(
|
||||||
__name__,
|
__name__,
|
||||||
@@ -103,8 +108,9 @@ if not logger.handlers:
|
|||||||
)
|
)
|
||||||
|
|
||||||
handler.setFormatter(
|
handler.setFormatter(
|
||||||
logging.Formatter(
|
UTCFormatter(
|
||||||
"%(asctime)s [%(levelname)s] %(name)s: %(message)s"
|
LOG_FORMAT,
|
||||||
|
datefmt=LOG_DATE_FORMAT,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+23
-28
@@ -1,7 +1,10 @@
|
|||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from logging_config import (
|
||||||
|
LOG_DATE_FORMAT,
|
||||||
|
LOG_FORMAT,
|
||||||
|
UTCFormatter,
|
||||||
|
)
|
||||||
|
|
||||||
def setup_logger():
|
def setup_logger():
|
||||||
|
|
||||||
@@ -13,36 +16,28 @@ def setup_logger():
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
file_handler = logging.FileHandler(
|
||||||
|
"logs/project.log"
|
||||||
|
)
|
||||||
|
console_handler = logging.StreamHandler()
|
||||||
|
|
||||||
|
for handler in (
|
||||||
|
file_handler,
|
||||||
|
console_handler,
|
||||||
|
):
|
||||||
|
handler.setFormatter(
|
||||||
|
UTCFormatter(
|
||||||
|
LOG_FORMAT,
|
||||||
|
datefmt=LOG_DATE_FORMAT,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
|
|
||||||
|
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
|
|
||||||
|
|
||||||
format=(
|
|
||||||
|
|
||||||
"%(asctime)s "
|
|
||||||
"[%(levelname)s] "
|
|
||||||
"%(name)s: "
|
|
||||||
"%(message)s"
|
|
||||||
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
handlers=[
|
handlers=[
|
||||||
|
file_handler,
|
||||||
|
console_handler,
|
||||||
logging.FileHandler(
|
],
|
||||||
"logs/project.log"
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
logging.StreamHandler()
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
LOG_FORMAT = (
|
||||||
|
"%(asctime)s.%(msecs)03dZ "
|
||||||
|
"[%(levelname)s] "
|
||||||
|
"%(name)s: "
|
||||||
|
"%(message)s"
|
||||||
|
)
|
||||||
|
|
||||||
|
LOG_DATE_FORMAT = "%Y-%m-%dT%H:%M:%S"
|
||||||
|
|
||||||
|
|
||||||
|
class UTCFormatter(logging.Formatter):
|
||||||
|
converter = staticmethod(time.gmtime)
|
||||||
+8
-2
@@ -9,6 +9,11 @@ from scapy.layers.dot11 import Dot11
|
|||||||
from scapy.layers.eap import EAPOL
|
from scapy.layers.eap import EAPOL
|
||||||
from bisect import bisect_left
|
from bisect import bisect_left
|
||||||
from vendor import VendorResolver
|
from vendor import VendorResolver
|
||||||
|
from logging_config import (
|
||||||
|
LOG_DATE_FORMAT,
|
||||||
|
LOG_FORMAT,
|
||||||
|
UTCFormatter,
|
||||||
|
)
|
||||||
|
|
||||||
class CaptureParser:
|
class CaptureParser:
|
||||||
|
|
||||||
@@ -64,8 +69,9 @@ class CaptureParser:
|
|||||||
session.parser_log
|
session.parser_log
|
||||||
)
|
)
|
||||||
|
|
||||||
formatter = logging.Formatter(
|
formatter = UTCFormatter(
|
||||||
"%(asctime)s [%(levelname)s] %(message)s"
|
LOG_FORMAT,
|
||||||
|
datefmt=LOG_DATE_FORMAT,
|
||||||
)
|
)
|
||||||
|
|
||||||
handler.setFormatter(
|
handler.setFormatter(
|
||||||
|
|||||||
Reference in New Issue
Block a user