Skip to content

Commit

Permalink
logger: Only create logfile if USER_PATH exists
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Dec 9, 2021
1 parent 52c3cdc commit 776ec10
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/classes/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,19 @@ def filter(self, record):
#
# Create rotating file handler
#
fh = logging.handlers.RotatingFileHandler(
os.path.join(info.USER_PATH, 'openshot-qt.log'),
encoding="utf-8",
maxBytes=25*1024*1024, backupCount=3)
fh.setLevel(info.LOG_LEVEL_FILE)
fh.setFormatter(file_formatter)

log.addHandler(fh)
if os.path.exists(info.USER_PATH):
fh = logging.handlers.RotatingFileHandler(
os.path.join(info.USER_PATH, 'openshot-qt.log'),
encoding="utf-8",
maxBytes=25*1024*1024, backupCount=3)
fh.setLevel(info.LOG_LEVEL_FILE)
fh.setFormatter(file_formatter)
log.addHandler(fh)
else:
class DummyHandler:
def setLevel(self, level):
return True
fh = DummyHandler()

#
# Create typical stream handler which logs to stderr
Expand Down Expand Up @@ -120,3 +125,4 @@ def set_level_file(level=logging.INFO):
def set_level_console(level=logging.INFO):
"""Adjust the minimum log level for output to the terminal"""
sh.setLevel(level)

0 comments on commit 776ec10

Please sign in to comment.