Skip to content

Commit

Permalink
Moved logging config to code
Browse files Browse the repository at this point in the history
  • Loading branch information
sowwic committed Jul 28, 2020
1 parent e3c611e commit b5e43c3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 41 deletions.
36 changes: 0 additions & 36 deletions configs/logging_config.ini

This file was deleted.

1 change: 0 additions & 1 deletion configs/version.ini

This file was deleted.

File renamed without changes.
21 changes: 18 additions & 3 deletions dsPlayblast/loggingFn.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
import logging.config
import logging.handlers
from dsPlayblast import util


def setup_logging():
log_file = "playblast.log"
config_file = util.resource_path("configs/logging_config.ini")
logging.config.fileConfig(config_file, defaults={'logfilename': log_file}, disable_existing_loggers=False)
# Formatters
brief_formatter = logging.Formatter(fmt="%(levelname)s | %(message)s", datefmt="%Y-%m-%d %H:%M")
verbose_formatter = logging.Formatter(fmt="%(asctime)s | %(levelname)s | %(name)s | %(message)s")
# Handlers
rfile_handler = logging.handlers.RotatingFileHandler(log_file, mode="a", maxBytes=1024, backupCount=1, delay=0)
rfile_handler.setLevel("DEBUG")
rfile_handler.setFormatter(verbose_formatter)
stream_handler = logging.StreamHandler()
stream_handler.setLevel("DEBUG")
stream_handler.setFormatter(brief_formatter)

# Root logger
logging.root.setLevel("DEBUG")
logging.root.addHandler(stream_handler)
logging.root.addHandler(rfile_handler)


if __name__ == "__main__":
print(util.resource_path("logging_config.ini"))
setup_logging()
logging.root.info("Root logger")
2 changes: 1 addition & 1 deletion make.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pyinstaller.exe --onedir --windowed --name dsPlayblast --icon=./images/dsPlayblast.ico ./dsPlayblast/main.py
pyinstaller.exe --onedir --windowed --name dsPlayblast --icon=./dsPlayblast/images/dsPlayblast.ico ./dsPlayblast/main.py
PAUSE

0 comments on commit b5e43c3

Please sign in to comment.