сократил формат логов в консоли
This commit is contained in:
29
main.py
29
main.py
@@ -1,14 +1,24 @@
|
|||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
logging.basicConfig(
|
|
||||||
level=logging.INFO,
|
def configure_logging(level: int = logging.INFO):
|
||||||
format='%(asctime)s %(name)s:%(lineno)d %(levelname)s %(message)s',
|
"""Настраивает короткий консольный лог и подробный файловый лог."""
|
||||||
handlers=[
|
file_handler = logging.FileHandler('app.log', encoding='utf-8')
|
||||||
logging.FileHandler('app.log', encoding='utf-8'),
|
file_handler.setFormatter(
|
||||||
logging.StreamHandler(sys.stdout)
|
logging.Formatter('%(asctime)s %(name)s:%(lineno)d %(levelname)s %(message)s')
|
||||||
]
|
)
|
||||||
)
|
file_handler.setLevel(level)
|
||||||
|
|
||||||
|
console_handler = logging.StreamHandler(sys.stdout)
|
||||||
|
console_handler.setFormatter(logging.Formatter('%(message)s'))
|
||||||
|
console_handler.setLevel(level)
|
||||||
|
|
||||||
|
logging.basicConfig(
|
||||||
|
level=level,
|
||||||
|
handlers=[file_handler, console_handler],
|
||||||
|
force=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
from api.clockify import ClockifyAPI # noqa: E402
|
from api.clockify import ClockifyAPI # noqa: E402
|
||||||
@@ -22,10 +32,11 @@ from utils import check_envs, db_update, get_start_end_dates # noqa: E402
|
|||||||
def main():
|
def main():
|
||||||
"""Запускает CLI-сценарий переноса трудочасов из Clockify в Redmine."""
|
"""Запускает CLI-сценарий переноса трудочасов из Clockify в Redmine."""
|
||||||
args = arg_parser.parse_args()
|
args = arg_parser.parse_args()
|
||||||
|
log_level = logging.DEBUG if args.debug else logging.INFO
|
||||||
|
configure_logging(log_level)
|
||||||
|
|
||||||
if is_debug := args.debug:
|
if is_debug := args.debug:
|
||||||
config.MODE = "debug"
|
config.MODE = "debug"
|
||||||
logging.getLogger().setLevel(logging.DEBUG)
|
|
||||||
if is_dry_run := args.dry_run:
|
if is_dry_run := args.dry_run:
|
||||||
config.MODE = "debug"
|
config.MODE = "debug"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user