Skip to content

Commit

Permalink
Log fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Feramance committed Oct 10, 2024
1 parent 3915556 commit 9a26c2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 6 additions & 5 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import contextlib
import itertools
import logging
import os
import pathlib
import re
import shutil
Expand Down Expand Up @@ -101,10 +100,8 @@ def __init__(
logfile = logs_folder.joinpath(self._name + ".log")
if pathlib.Path(logfile).is_file():
logold = logs_folder.joinpath(self._name + ".log.old")
try:
os.remove(logold)
except FileNotFoundError:
pass
if pathlib.Path(logold).exists():
logold.unlink()
logfile.rename(logold)
fh = logging.FileHandler(logfile)
self.logger.addHandler(fh)
Expand Down Expand Up @@ -4926,6 +4923,8 @@ def __init__(self, name: str, manager: ArrManager):
logfile = logs_folder.joinpath(self._name + ".log")
if pathlib.Path(logfile).is_file():
logold = logs_folder.joinpath(self._name + ".log.old")
if pathlib.Path(logold).exists():
logold.unlink()
logfile.rename(logold)
fh = logging.FileHandler(logfile)
self.logger.addHandler(fh)
Expand Down Expand Up @@ -5060,6 +5059,8 @@ def __init__(self, categories: set[str], manager: ArrManager):
logfile = logs_folder.joinpath(self._name + ".log")
if pathlib.Path(logfile).is_file():
logold = logs_folder.joinpath(self._name + ".log.old")
if pathlib.Path(logold).exists():
logold.unlink()
logfile.rename(logold)
fh = logging.FileHandler(logfile)
self.logger.addHandler(fh)
Expand Down
14 changes: 9 additions & 5 deletions qBitrr/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@

logger = logging.getLogger("qBitrr")
# if ENABLE_LOGS:
# LOGS_FOLDER = HOME_PATH.joinpath("logs")
# LOGS_FOLDER.mkdir(parents=True, exist_ok=True)
# LOGS_FOLDER.chmod(mode=0o777)
# logfile = LOGS_FOLDER.joinpath("qBitrr.log")
# logs_folder = HOME_PATH.joinpath("logs")
# logs_folder.mkdir(parents=True, exist_ok=True)
# logs_folder.chmod(mode=0o777)
# logfile = logs_folder.joinpath("qBitrr.log")
# if pathlib.Path(logfile).is_file():
# logold = LOGS_FOLDER.joinpath("qBitrr.log.old")
# logold = logs_folder.joinpath( "qBitrr.log.old")
# if pathlib.Path(logold).exists():
# logold.unlink()
# logfile.rename(logold)
# fh = logging.FileHandler(logfile)
# logger.addHandler(fh)
Expand All @@ -74,6 +76,8 @@ def __init__(self):
logfile = logs_folder.joinpath(self._name + ".log")
if pathlib.Path(logfile).is_file():
logold = logs_folder.joinpath(self._name + ".log.old")
if pathlib.Path(logold).exists():
logold.unlink()
logfile.rename(logold)
fh = logging.FileHandler(logfile)
self.logger.addHandler(fh)
Expand Down

0 comments on commit 9a26c2a

Please sign in to comment.