add basic timestamp formatting
This commit is contained in:
parent
1b0e16d97b
commit
134ef07fd5
@ -13,10 +13,10 @@ import cleanupagents.Utils
|
|||||||
from cleanupagents.Utils import Singleton
|
from cleanupagents.Utils import Singleton
|
||||||
from cleanupagents.Utils import to_bool
|
from cleanupagents.Utils import to_bool
|
||||||
|
|
||||||
CONSOLE_FORMAT = "%(asctime)s {}[%(levelname)s]{} %(message)s"
|
CONSOLE_FORMAT = "{}[%(levelname)s]{} %(message)s"
|
||||||
FILE_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
FILE_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
||||||
JSON_FORMAT = "(asctime) (levelname) (message)"
|
JSON_FORMAT = "(asctime) (levelname) (message)"
|
||||||
|
TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
|
||||||
|
|
||||||
def _should_do_markup():
|
def _should_do_markup():
|
||||||
py_colors = os.environ.get("PY_COLORS", None)
|
py_colors = os.environ.get("PY_COLORS", None)
|
||||||
@ -85,7 +85,7 @@ class Log:
|
|||||||
def _get_file_handler(self, logfile, json=False):
|
def _get_file_handler(self, logfile, json=False):
|
||||||
handler = logging.handlers.RotatingFileHandler(logfile, maxBytes=512000, backupCount=5)
|
handler = logging.handlers.RotatingFileHandler(logfile, maxBytes=512000, backupCount=5)
|
||||||
handler.setLevel(logging.DEBUG)
|
handler.setLevel(logging.DEBUG)
|
||||||
handler.setFormatter(logging.Formatter(FILE_FORMAT))
|
handler.setFormatter(logging.Formatter(FILE_FORMAT, TIME_FORMAT))
|
||||||
|
|
||||||
if json:
|
if json:
|
||||||
handler.setFormatter(MultilineJsonFormatter(JSON_FORMAT))
|
handler.setFormatter(MultilineJsonFormatter(JSON_FORMAT))
|
||||||
|
Reference in New Issue
Block a user