Implemented new default log paths, closes #48

This commit is contained in:
deajan 2024-05-09 17:36:44 +02:00
parent 748bafb2b4
commit ae15e087c4
2 changed files with 10 additions and 3 deletions

View file

@ -13,6 +13,7 @@ import atexit
from time import sleep
from argparse import ArgumentParser
from datetime import datetime, timezone
from tempfile import gettempdir
import logging
import json
import ofunctions.logger_utils
@ -264,7 +265,10 @@ This is free software, and you are welcome to redistribute it under certain cond
if args.log_file:
log_file = args.log_file
else:
log_file = os.path.join(CURRENT_DIR, "{}.log".format(__intname__))
if os.name == "nt":
log_file = os.path.join(gettempdir(), "{}.log".format(__intname__))
else:
log_file = "/var/log/{}.log".format(__intname__)
if args.json:
_JSON = True

View file

@ -7,7 +7,6 @@ __intname__ = "npbackup.gui.main"
__author__ = "Orsiris de Jong"
__copyright__ = "Copyright (C) 2022-2024 NetInvent"
__license__ = "GPL-3.0-only"
__build__ = "2023121701"
from typing import List, Optional, Tuple
@ -21,6 +20,7 @@ import ofunctions.logger_utils
from datetime import datetime, timezone
import dateutil
from time import sleep
from tempfile import gettempdir
from ruamel.yaml.comments import CommentedMap
import atexit
from ofunctions.process import kill_childs
@ -659,7 +659,10 @@ def _main_gui(viewer_mode: bool):
if args.log_file:
log_file = args.log_file
else:
log_file = os.path.join(CURRENT_DIR, "{}.log".format(__intname__))
if os.name == "nt":
log_file = os.path.join(gettempdir(), "{}.log".format(__intname__))
else:
log_file = "/var/log/{}.log".format(__intname__)
logger = ofunctions.logger_utils.logger_get_logger(log_file, debug=_DEBUG)
if args.config_file: