Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Adding loglevel adjustable in the settings file #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cleaner.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"IgnoreSections": [],
"LogFile": "",
"LogFileMode": "",
"LogLevel": 10,
"trigger_rescan": false,
"EmailLog": false,
"EmailServer": "",
Expand Down
4 changes: 3 additions & 1 deletion PlexCleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
IgnoreSections = [] # Sections to skip cleaning, for use when Settings['SectionList'] is not specified, the same as SectionList, the section id should be used here
LogFile = "" # Location of log file to save console output
LogFileMode = "overwrite" # File Mode for logging, overwrite or append, default is overwrite
LogLevel = 10 #Level for Logging, default is debug, 10=DEBUG 20=INFO 30=WARNING 40=ERROR 50=CRITICAL
trigger_rescan = False # trigger_rescan will rescan a section if changes are made to it
EmailLog = False # Email the log file contents at conclusion of script
EmailServer = "" # Email Server (for Gmail, use smtp.gmail.com)
Expand Down Expand Up @@ -346,6 +347,7 @@ def LoadSettings(opts):
s['IgnoreSections'] = opts.get('IgnoreSections', IgnoreSections)
s['LogFile'] = opts.get('LogFile', LogFile)
s['LogFileMode'] = opts.get('LogFileMode', LogFileMode)
s['LogLevel'] = opts.get('LogLevel', LogLevel)
s['trigger_rescan'] = opts.get('trigger_rescan', trigger_rescan)
s['EmailLog'] = opts.get('EmailLog', EmailLog)
s['EmailServer'] = opts.get('EmailServer', EmailServer)
Expand Down Expand Up @@ -1105,7 +1107,7 @@ def sendEmail(email_from, email_to, subject, body, server, port, username="", pa
filemode = "w"
if Settings.get("LogFileMode").startswith("a"):
filemode = "a"
logging.basicConfig(filename=Settings['LogFile'], filemode=filemode, level=logging.DEBUG)
logging.basicConfig(filename=Settings['LogFile'], filemode=filemode, level=Settings['LogLevel'])
logging.captureWarnings(True)

log("** Script started " + time.strftime("%m-%d-%Y %I:%M:%S%p"))
Expand Down