mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-22 06:13:19 -07:00
Added function for configuring logging
This commit is contained in:
parent
2d351c303a
commit
b757f333ed
2 changed files with 37 additions and 24 deletions
|
@ -11,14 +11,12 @@ import linktastic.linktastic as linktastic
|
||||||
import autoProcessMovie
|
import autoProcessMovie
|
||||||
import autoProcessTV
|
import autoProcessTV
|
||||||
from nzbToMediaEnv import *
|
from nzbToMediaEnv import *
|
||||||
|
from nzbToMediaUtil import *
|
||||||
|
|
||||||
|
|
||||||
|
nzbtomedia_configure_logging(os.path.dirname(sys.argv[0]))
|
||||||
|
Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
Logger = logging.getLogger()
|
|
||||||
logFile = os.path.join(os.path.dirname(sys.argv[0]), "postprocess.log")
|
|
||||||
logging.config.fileConfig(os.path.join(os.path.dirname(sys.argv[0]), "logger.conf"))
|
|
||||||
fileHandler = logging.FileHandler(logFile, encoding='utf-8', delay=True)
|
|
||||||
fileHandler.formatter = logging.Formatter('%(asctime)s|%(levelname)-7.7s %(message)s', '%H:%M:%S')
|
|
||||||
fileHandler.level = logging.DEBUG
|
|
||||||
Logger.addHandler(fileHandler)
|
|
||||||
|
|
||||||
def removeEmptyFolders(path):
|
def removeEmptyFolders(path):
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
|
@ -39,11 +37,12 @@ def removeEmptyFolders(path):
|
||||||
os.rmdir(path)
|
os.rmdir(path)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#old_stdout = sys.stdout #backup the default stdout
|
#old_stdout = sys.stdout #backup the default stdout
|
||||||
#log_file = open(os.path.join(os.path.dirname(sys.argv[0]), "postprocess.log"),"a+")
|
#log_file = open(os.path.join(os.path.dirname(sys.argv[0]), "postprocess.log"),"a+")
|
||||||
#sys.stdout = log_file #create a local log file, and direct all "print" to the log.
|
#sys.stdout = log_file #create a local log file, and direct all "print" to the log.
|
||||||
Logger.info("TorrentToMedia %s", VERSION)
|
Logger.info("TorrentToMedia %s", VERSION)
|
||||||
|
|
||||||
|
|
||||||
if len(sys.argv) == 4:
|
if len(sys.argv) == 4:
|
||||||
##You can use the following parameters (UTORRENT):
|
##You can use the following parameters (UTORRENT):
|
||||||
##
|
##
|
||||||
|
|
14
nzbToMediaUtil.py
Normal file
14
nzbToMediaUtil.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import logging.config
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
|
||||||
|
def nzbtomedia_configure_logging(dirname):
|
||||||
|
logFile = os.path.join(dirname, "postprocess.log")
|
||||||
|
logging.config.fileConfig(os.path.join(dirname, "logger.conf"))
|
||||||
|
fileHandler = logging.FileHandler(logFile, encoding='utf-8', delay=True)
|
||||||
|
fileHandler.formatter = logging.Formatter('%(asctime)s|%(levelname)-7.7s %(message)s', '%H:%M:%S')
|
||||||
|
fileHandler.level = logging.DEBUG
|
||||||
|
logging.getLogger().addHandler(fileHandler)
|
Loading…
Add table
Add a link
Reference in a new issue