mirror of https://github.com/evilhero/mylar
This commit is contained in:
parent
a895f3f8d3
commit
127b109011
31
Mylar.py
31
Mylar.py
|
@ -62,17 +62,10 @@ def main():
|
||||||
if not mylar.SYS_ENCODING or mylar.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
|
if not mylar.SYS_ENCODING or mylar.SYS_ENCODING in ('ANSI_X3.4-1968', 'US-ASCII', 'ASCII'):
|
||||||
mylar.SYS_ENCODING = 'UTF-8'
|
mylar.SYS_ENCODING = 'UTF-8'
|
||||||
|
|
||||||
#setup logger for non-english
|
if not logger.LOG_LANG.startswith('en'):
|
||||||
try:
|
print 'language detected as non-English (%s). Forcing specific logging module - errors WILL NOT be captured in the logs' % logger.LOG_LANG
|
||||||
language = locale.getdefaultlocale()[0][:2]
|
|
||||||
except:
|
|
||||||
language = 'en'
|
|
||||||
|
|
||||||
mylar.LOG_LANG = language
|
|
||||||
if language != 'en':
|
|
||||||
print 'language detected as non-English. Forcing specific logging module - errors WILL NOT be captured in the logs'
|
|
||||||
else:
|
else:
|
||||||
print 'log language set to %s' % mylar.LOG_LANG
|
print 'log language set to %s' % logger.LOG_LANG
|
||||||
|
|
||||||
# Set up and gather command line arguments
|
# Set up and gather command line arguments
|
||||||
parser = argparse.ArgumentParser(description='Automated Comic Book Downloader')
|
parser = argparse.ArgumentParser(description='Automated Comic Book Downloader')
|
||||||
|
@ -109,22 +102,14 @@ def main():
|
||||||
mylar.MAINTENANCE = False
|
mylar.MAINTENANCE = False
|
||||||
|
|
||||||
if args.verbose:
|
if args.verbose:
|
||||||
mylar.VERBOSE = True
|
print 'Verbose/Debugging mode enabled...'
|
||||||
#print 'Verbose/Debugging mode enabled...'
|
mylar.LOG_LEVEL = 2
|
||||||
#mylar.LOG_LEVEL = 2
|
|
||||||
elif args.quiet:
|
elif args.quiet:
|
||||||
mylar.QUIET = True
|
mylar.QUIET = True
|
||||||
#print 'Quiet mode enabled...'
|
print 'Quiet logging mode enabled...'
|
||||||
#mylar.LOG_LEVEL = 0
|
mylar.LOG_LEVEL = 0
|
||||||
else:
|
else:
|
||||||
#print 'Normal logging mode enabled...'
|
mylar.LOG_LEVEL = 1
|
||||||
#mylar.LOG_LEVEL = 1
|
|
||||||
mylar.VERBOSE = False
|
|
||||||
|
|
||||||
# Do an intial setup of the logger.
|
|
||||||
if mylar.LOG_LANG == 'en':
|
|
||||||
logger.initLogger(console=not mylar.QUIET, log_dir=False, init=True, verbose=mylar.VERBOSE)
|
|
||||||
#logger.mylar_log.initLogger(loglevel=mylar.LOG_LEVEL)
|
|
||||||
|
|
||||||
if args.daemon:
|
if args.daemon:
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
|
|
|
@ -40,7 +40,8 @@
|
||||||
<legend>Configuration Options</legend>
|
<legend>Configuration Options</legend>
|
||||||
<div>
|
<div>
|
||||||
<label><strong>Mylar Version: </strong> ${config['branch']}</br> -- ${config['br_type']} build ${config['br_version']}.</label></br>
|
<label><strong>Mylar Version: </strong> ${config['branch']}</br> -- ${config['br_type']} build ${config['br_version']}.</label></br>
|
||||||
<label><strong>Python Version :</strong> ${config['py_version']}</label></br></br>
|
<label><strong>Python Version :</strong> ${config['py_version']}</label></br>
|
||||||
|
<label><strong>Language :</strong> ${config['lang']}</label></br></br>
|
||||||
<legend>MYLAR PROGRAM OPTIONS</legend>
|
<legend>MYLAR PROGRAM OPTIONS</legend>
|
||||||
<label><strong>Mylar Data Directory :</strong> ${config['data_dir']}</label></br>
|
<label><strong>Mylar Data Directory :</strong> ${config['data_dir']}</label></br>
|
||||||
<label><strong>Mylar Program Directory :</strong> ${config['prog_dir']}</label></br>
|
<label><strong>Mylar Program Directory :</strong> ${config['prog_dir']}</label></br>
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
<div id="subhead_container">
|
<div id="subhead_container">
|
||||||
<div id="subhead_menu">
|
<div id="subhead_menu">
|
||||||
<a id="menu_link_delete" href="#" onclick="doAjaxCall('clearLogs',$(this),'table')" data-success="All logs cleared">Clear Log</a>
|
<a id="menu_link_delete" href="#" onclick="doAjaxCall('clearLogs',$(this),'table')" data-success="All logs cleared">Clear Log</a>
|
||||||
<a id="menu_link_edit" href="toggleVerbose">Toggle Debug Log
|
<a id="menu_link_edit" href="toggleVerbose">Toggle Debug Logging
|
||||||
%if mylar.VERBOSE:
|
%if mylar.LOG_LEVEL < 2:
|
||||||
ON
|
ON
|
||||||
|
%else:
|
||||||
|
OFF
|
||||||
%endif
|
%endif
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -40,7 +40,6 @@ import cherrypy
|
||||||
|
|
||||||
from mylar import logger, versioncheckit, rsscheckit, searchit, weeklypullit, PostProcessor, updater, helpers
|
from mylar import logger, versioncheckit, rsscheckit, searchit, weeklypullit, PostProcessor, updater, helpers
|
||||||
|
|
||||||
from mylar import versioncheck, logger
|
|
||||||
import mylar.config
|
import mylar.config
|
||||||
|
|
||||||
#these are the globals that are runtime-based (ie. not config-valued at all)
|
#these are the globals that are runtime-based (ie. not config-valued at all)
|
||||||
|
@ -52,13 +51,15 @@ MAINTENANCE = False
|
||||||
LOG_DIR = None
|
LOG_DIR = None
|
||||||
LOGTYPE = 'log'
|
LOGTYPE = 'log'
|
||||||
LOG_LANG = 'en'
|
LOG_LANG = 'en'
|
||||||
|
LOG_CHARSET = 'UTF-8'
|
||||||
|
LOG_LEVEL = 1
|
||||||
LOGLIST = []
|
LOGLIST = []
|
||||||
ARGS = None
|
ARGS = None
|
||||||
SIGNAL = None
|
SIGNAL = None
|
||||||
SYS_ENCODING = None
|
SYS_ENCODING = None
|
||||||
OS_DETECT = platform.system()
|
OS_DETECT = platform.system()
|
||||||
USER_AGENT = None
|
USER_AGENT = None
|
||||||
VERBOSE = False
|
#VERBOSE = False
|
||||||
DAEMON = False
|
DAEMON = False
|
||||||
PIDFILE= None
|
PIDFILE= None
|
||||||
CREATEPID = False
|
CREATEPID = False
|
||||||
|
@ -159,23 +160,17 @@ def initialize(config_file):
|
||||||
IMPORTBUTTON, IMPORT_FILES, IMPORT_TOTALFILES, IMPORT_CID_COUNT, IMPORT_PARSED_COUNT, IMPORT_FAILURE_COUNT, CHECKENABLED, CVURL, DEMURL, WWTURL, \
|
IMPORTBUTTON, IMPORT_FILES, IMPORT_TOTALFILES, IMPORT_CID_COUNT, IMPORT_PARSED_COUNT, IMPORT_FAILURE_COUNT, CHECKENABLED, CVURL, DEMURL, WWTURL, \
|
||||||
USE_SABNZBD, USE_NZBGET, USE_BLACKHOLE, USE_RTORRENT, USE_UTORRENT, USE_QBITTORRENT, USE_DELUGE, USE_TRANSMISSION, USE_WATCHDIR, SAB_PARAMS, \
|
USE_SABNZBD, USE_NZBGET, USE_BLACKHOLE, USE_RTORRENT, USE_UTORRENT, USE_QBITTORRENT, USE_DELUGE, USE_TRANSMISSION, USE_WATCHDIR, SAB_PARAMS, \
|
||||||
PROG_DIR, DATA_DIR, CMTAGGER_PATH, DOWNLOAD_APIKEY, LOCAL_IP, STATIC_COMICRN_VERSION, STATIC_APC_VERSION, KEYS_32P, AUTHKEY_32P, FEED_32P, FEEDINFO_32P, \
|
PROG_DIR, DATA_DIR, CMTAGGER_PATH, DOWNLOAD_APIKEY, LOCAL_IP, STATIC_COMICRN_VERSION, STATIC_APC_VERSION, KEYS_32P, AUTHKEY_32P, FEED_32P, FEEDINFO_32P, \
|
||||||
MONITOR_STATUS, SEARCH_STATUS, RSS_STATUS, WEEKLY_STATUS, VERSION_STATUS, UPDATER_STATUS, DBUPDATE_INTERVAL, LOG_LEVEL, LOG_LANG, APILOCK, \
|
MONITOR_STATUS, SEARCH_STATUS, RSS_STATUS, WEEKLY_STATUS, VERSION_STATUS, UPDATER_STATUS, DBUPDATE_INTERVAL, LOG_LANG, LOG_CHARSET, APILOCK, LOG_LEVEL, \
|
||||||
SCHED_RSS_LAST, SCHED_WEEKLY_LAST, SCHED_MONITOR_LAST, SCHED_SEARCH_LAST, SCHED_VERSION_LAST, SCHED_DBUPDATE_LAST, COMICINFO
|
SCHED_RSS_LAST, SCHED_WEEKLY_LAST, SCHED_MONITOR_LAST, SCHED_SEARCH_LAST, SCHED_VERSION_LAST, SCHED_DBUPDATE_LAST, COMICINFO
|
||||||
|
|
||||||
cc = mylar.config.Config(config_file)
|
cc = mylar.config.Config(config_file)
|
||||||
CONFIG = cc.read()
|
CONFIG = cc.read(startup=True)
|
||||||
|
|
||||||
assert CONFIG is not None
|
assert CONFIG is not None
|
||||||
|
|
||||||
if _INITIALIZED:
|
if _INITIALIZED:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Start the logger, silence console logging if we need to
|
|
||||||
if mylar.LOG_LANG == 'en':
|
|
||||||
logger.initLogger(console=not QUIET, log_dir=CONFIG.LOG_DIR, verbose=VERBOSE)
|
|
||||||
else:
|
|
||||||
logger.mylar_log.initLogger(loglevel=mylar.LOG_LEVEL)
|
|
||||||
|
|
||||||
# Also sets INSTALL_TYPE variable to 'win', 'git' or 'source'
|
# Also sets INSTALL_TYPE variable to 'win', 'git' or 'source'
|
||||||
CURRENT_VERSION, CONFIG.GIT_BRANCH = versioncheck.getVersion()
|
CURRENT_VERSION, CONFIG.GIT_BRANCH = versioncheck.getVersion()
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ _CONFIG_DEFINITIONS = OrderedDict({
|
||||||
'LOG_DIR' : (str, 'Logs', None),
|
'LOG_DIR' : (str, 'Logs', None),
|
||||||
'MAX_LOGSIZE' : (int, 'Logs', 10000000),
|
'MAX_LOGSIZE' : (int, 'Logs', 10000000),
|
||||||
'MAX_LOGFILES': (int, 'Logs', 5),
|
'MAX_LOGFILES': (int, 'Logs', 5),
|
||||||
'LOG_LEVEL': (int, 'Logs', 0),
|
'LOG_LEVEL': (int, 'Logs', 1),
|
||||||
|
|
||||||
'GIT_PATH' : (str, 'Git', None),
|
'GIT_PATH' : (str, 'Git', None),
|
||||||
'GIT_USER' : (str, 'Git', 'evilhero'),
|
'GIT_USER' : (str, 'Git', 'evilhero'),
|
||||||
|
@ -479,7 +479,7 @@ class Config(object):
|
||||||
elif k == 'MINIMAL_INI':
|
elif k == 'MINIMAL_INI':
|
||||||
config.set(v[1], k.lower(), str(self.MINIMAL_INI))
|
config.set(v[1], k.lower(), str(self.MINIMAL_INI))
|
||||||
|
|
||||||
def read(self):
|
def read(self, startup=False):
|
||||||
self.config_vals()
|
self.config_vals()
|
||||||
setattr(self, 'EXTRA_NEWZNABS', self.get_extra_newznabs())
|
setattr(self, 'EXTRA_NEWZNABS', self.get_extra_newznabs())
|
||||||
setattr(self, 'EXTRA_TORZNABS', self.get_extra_torznabs())
|
setattr(self, 'EXTRA_TORZNABS', self.get_extra_torznabs())
|
||||||
|
@ -498,6 +498,16 @@ class Config(object):
|
||||||
self.writeconfig()
|
self.writeconfig()
|
||||||
else:
|
else:
|
||||||
self.provider_sequence()
|
self.provider_sequence()
|
||||||
|
|
||||||
|
if startup is True:
|
||||||
|
# Start the logger, silence console logging if we need to
|
||||||
|
if logger.LOG_LANG.startswith('en'):
|
||||||
|
logger.initLogger(console=not mylar.QUIET, log_dir=self.LOG_DIR, max_logsize=self.MAX_LOGSIZE, max_logfiles=self.MAX_LOGFILES, loglevel=mylar.LOG_LEVEL)
|
||||||
|
else:
|
||||||
|
if self.LOG_LEVEL != mylar.LOG_LEVEL:
|
||||||
|
print('Logging level over-ridden by startup value. Changing from %s to %s' % (self.LOG_LEVEL, mylar.LOG_LEVEL))
|
||||||
|
logger.mylar_log.initLogger(loglevel=mylar.LOG_LEVEL, log_dir=self.LOG_DIR, max_logsize=self.MAX_LOGSIZE, max_logfiles=self.MAX_LOGFILES)
|
||||||
|
|
||||||
self.configure()
|
self.configure()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
@ -695,6 +705,7 @@ class Config(object):
|
||||||
logger.warn("Error writing configuration file: %s", e)
|
logger.warn("Error writing configuration file: %s", e)
|
||||||
|
|
||||||
def configure(self, update=False):
|
def configure(self, update=False):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not any([self.SAB_HOST is None, self.SAB_HOST == '', 'http://' in self.SAB_HOST[:7], 'https://' in self.SAB_HOST[:8]]):
|
if not any([self.SAB_HOST is None, self.SAB_HOST == '', 'http://' in self.SAB_HOST[:7], 'https://' in self.SAB_HOST[:8]]):
|
||||||
self.SAB_HOST = 'http://' + self.SAB_HOST
|
self.SAB_HOST = 'http://' + self.SAB_HOST
|
||||||
|
|
|
@ -15,24 +15,30 @@
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import inspect
|
||||||
import traceback
|
import traceback
|
||||||
import threading
|
import threading
|
||||||
import platform
|
import platform
|
||||||
|
import locale
|
||||||
import mylar
|
import mylar
|
||||||
|
|
||||||
from logging import getLogger, WARN, ERROR, INFO, DEBUG, StreamHandler, Formatter, Handler
|
|
||||||
|
|
||||||
from mylar import helpers
|
from mylar import helpers
|
||||||
|
import logging
|
||||||
|
from logging import getLogger, WARN, ERROR, INFO, DEBUG, StreamHandler, Formatter, Handler
|
||||||
|
from lib.six import PY2
|
||||||
|
|
||||||
|
#setup logger for non-english (this doesnt carry thru, so check here too)
|
||||||
try:
|
try:
|
||||||
if mylar.LOG_LANG == 'en':
|
localeinfo = locale.getdefaultlocale()
|
||||||
pass
|
language = localeinfo[0]
|
||||||
|
charset = localeinfo[1]
|
||||||
except:
|
except:
|
||||||
mylar.LOG_LANG = 'en'
|
language = 'en'
|
||||||
|
charset = 'UTF-8'
|
||||||
|
|
||||||
|
LOG_LANG = language
|
||||||
|
LOG_CHARSET = charset
|
||||||
|
|
||||||
if mylar.LOG_LANG != 'en':
|
if not LOG_LANG.startswith('en'):
|
||||||
# Simple rotating log handler that uses RotatingFileHandler
|
# Simple rotating log handler that uses RotatingFileHandler
|
||||||
class RotatingLogger(object):
|
class RotatingLogger(object):
|
||||||
|
|
||||||
|
@ -55,7 +61,7 @@ if mylar.LOG_LANG != 'en':
|
||||||
sys.__excepthook__(exc_type, exc_value, None)
|
sys.__excepthook__(exc_type, exc_value, None)
|
||||||
return
|
return
|
||||||
|
|
||||||
def initLogger(self, loglevel=1):
|
def initLogger(self, loglevel=1, log_dir=None, max_logsize=None, max_logfiles=None):
|
||||||
import sys
|
import sys
|
||||||
sys.excepthook = RotatingLogger.handle_exception
|
sys.excepthook = RotatingLogger.handle_exception
|
||||||
|
|
||||||
|
@ -66,7 +72,7 @@ if mylar.LOG_LANG != 'en':
|
||||||
lg = logging.getLogger('mylar')
|
lg = logging.getLogger('mylar')
|
||||||
lg.setLevel(logging.DEBUG)
|
lg.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
self.filename = os.path.join(mylar.CONFIG.LOG_DIR, self.filename)
|
self.filename = os.path.join(log_dir, self.filename)
|
||||||
|
|
||||||
#concurrentLogHandler/0.8.7 (to deal with windows locks)
|
#concurrentLogHandler/0.8.7 (to deal with windows locks)
|
||||||
#since this only happens on windows boxes, if it's nix/mac use the default logger.
|
#since this only happens on windows boxes, if it's nix/mac use the default logger.
|
||||||
|
@ -87,8 +93,8 @@ if mylar.LOG_LANG != 'en':
|
||||||
|
|
||||||
filehandler = RFHandler(
|
filehandler = RFHandler(
|
||||||
self.filename,
|
self.filename,
|
||||||
maxBytes=mylar.CONFIG.MAX_LOGSIZE,
|
maxBytes=max_logsize,
|
||||||
backupCount=mylar.CONFIG.MAX_LOGFILES)
|
backupCount=max_logfiles)
|
||||||
|
|
||||||
filehandler.setLevel(logging.DEBUG)
|
filehandler.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
@ -130,7 +136,7 @@ if mylar.LOG_LANG != 'en':
|
||||||
message = safe_unicode(message)
|
message = safe_unicode(message)
|
||||||
message = message.encode(mylar.SYS_ENCODING)
|
message = message.encode(mylar.SYS_ENCODING)
|
||||||
if level != 'DEBUG' or mylar.LOG_LEVEL >= 2:
|
if level != 'DEBUG' or mylar.LOG_LEVEL >= 2:
|
||||||
mylar.LOGLIST.insert(0, (helpers.now(), message, threadname))
|
mylar.LOGLIST.insert(0, (helpers.now(), message, level, threadname))
|
||||||
if len(mylar.LOGLIST) > 2500:
|
if len(mylar.LOGLIST) > 2500:
|
||||||
del mylar.LOGLIST[-1]
|
del mylar.LOGLIST[-1]
|
||||||
|
|
||||||
|
@ -189,8 +195,7 @@ else:
|
||||||
message = message.replace("\n", "<br />")
|
message = message.replace("\n", "<br />")
|
||||||
mylar.LOGLIST.insert(0, (helpers.now(), message, record.levelname, record.threadName))
|
mylar.LOGLIST.insert(0, (helpers.now(), message, record.levelname, record.threadName))
|
||||||
|
|
||||||
|
def initLogger(console=False, log_dir=False, init=False, loglevel=1, max_logsize=None, max_logfiles=5):
|
||||||
def initLogger(console=False, log_dir=False, init=False, verbose=False):
|
|
||||||
#concurrentLogHandler/0.8.7 (to deal with windows locks)
|
#concurrentLogHandler/0.8.7 (to deal with windows locks)
|
||||||
#since this only happens on windows boxes, if it's nix/mac use the default logger.
|
#since this only happens on windows boxes, if it's nix/mac use the default logger.
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
|
@ -208,13 +213,11 @@ else:
|
||||||
mylar.LOGTYPE = 'log'
|
mylar.LOGTYPE = 'log'
|
||||||
from logging.handlers import RotatingFileHandler as RFHandler
|
from logging.handlers import RotatingFileHandler as RFHandler
|
||||||
|
|
||||||
if init is True:
|
if all([init is True, max_logsize is None]):
|
||||||
max_size = 1000000 #1 MB
|
max_logsize = 1000000 #1 MB
|
||||||
else:
|
else:
|
||||||
if mylar.CONFIG.MAX_LOGSIZE:
|
if max_logsize is None:
|
||||||
max_size = mylar.CONFIG.MAX_LOGSIZE
|
max_logsize = 1000000 # 1 MB
|
||||||
else:
|
|
||||||
max_size = 1000000 # 1 MB
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Setup logging for Mylar. It uses the logger instance with the name
|
Setup logging for Mylar. It uses the logger instance with the name
|
||||||
|
@ -245,16 +248,13 @@ else:
|
||||||
# Configure the logger to accept all messages
|
# Configure the logger to accept all messages
|
||||||
logger.propagate = False
|
logger.propagate = False
|
||||||
|
|
||||||
#1 is WARN level, 2 is ERROR
|
|
||||||
if init is True:
|
if init is True:
|
||||||
logger.setLevel(logging.DEBUG if verbose else logging.INFO)
|
logger.setLevel(logging.INFO)
|
||||||
else:
|
else:
|
||||||
if mylar.CONFIG.LOG_LEVEL == 1:
|
if loglevel == 1: #normal
|
||||||
logger.setLevel(logging.DEBUG if verbose else logging.WARN)
|
logger.setLevel(logging.INFO)
|
||||||
elif mylar.CONFIG.LOG_LEVEL == 2:
|
elif loglevel >= 2: #verbose
|
||||||
logger.setLevel(logging.DEBUG if verbose else logging.ERROR)
|
logger.setLevel(logging.DEBUG)
|
||||||
else:
|
|
||||||
logger.setLevel(logging.DEBUG if verbose else logging.INFO)
|
|
||||||
|
|
||||||
# Add list logger
|
# Add list logger
|
||||||
loglist_handler = LogListHandler()
|
loglist_handler = LogListHandler()
|
||||||
|
@ -265,8 +265,11 @@ else:
|
||||||
if log_dir:
|
if log_dir:
|
||||||
filename = os.path.join(log_dir, 'mylar.log')
|
filename = os.path.join(log_dir, 'mylar.log')
|
||||||
file_formatter = Formatter('%(asctime)s - %(levelname)-7s :: %(name)s.%(funcName)s.%(lineno)s : %(threadName)s : %(message)s', '%d-%b-%Y %H:%M:%S')
|
file_formatter = Formatter('%(asctime)s - %(levelname)-7s :: %(name)s.%(funcName)s.%(lineno)s : %(threadName)s : %(message)s', '%d-%b-%Y %H:%M:%S')
|
||||||
file_handler = RFHandler(filename, "a", maxBytes=max_size, backupCount=mylar.CONFIG.MAX_LOGFILES)
|
file_handler = RFHandler(filename, "a", maxBytes=max_logsize, backupCount=max_logfiles)
|
||||||
file_handler.setLevel(logging.DEBUG)
|
if loglevel == 1: #normal
|
||||||
|
file_handler.setLevel(logging.INFO)
|
||||||
|
elif loglevel >= 2: #verbose
|
||||||
|
file_handler.setLevel(logging.DEBUG)
|
||||||
file_handler.setFormatter(file_formatter)
|
file_handler.setFormatter(file_formatter)
|
||||||
|
|
||||||
logger.addHandler(file_handler)
|
logger.addHandler(file_handler)
|
||||||
|
@ -276,7 +279,10 @@ else:
|
||||||
console_formatter = logging.Formatter('%(asctime)s - %(levelname)s :: %(name)s.%(funcName)s.%(lineno)s : %(threadName)s : %(message)s', '%d-%b-%Y %H:%M:%S')
|
console_formatter = logging.Formatter('%(asctime)s - %(levelname)s :: %(name)s.%(funcName)s.%(lineno)s : %(threadName)s : %(message)s', '%d-%b-%Y %H:%M:%S')
|
||||||
console_handler = logging.StreamHandler()
|
console_handler = logging.StreamHandler()
|
||||||
console_handler.setFormatter(console_formatter)
|
console_handler.setFormatter(console_formatter)
|
||||||
console_handler.setLevel(logging.DEBUG)
|
if loglevel == 1: #normal
|
||||||
|
console_handler.setLevel(logging.INFO)
|
||||||
|
elif loglevel >= 2: #verbose
|
||||||
|
console_handler.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
logger.addHandler(console_handler)
|
logger.addHandler(console_handler)
|
||||||
|
|
||||||
|
|
|
@ -3552,11 +3552,24 @@ class WebInterface(object):
|
||||||
clearLogs.exposed = True
|
clearLogs.exposed = True
|
||||||
|
|
||||||
def toggleVerbose(self):
|
def toggleVerbose(self):
|
||||||
mylar.VERBOSE = not mylar.VERBOSE
|
if mylar.LOG_LEVEL != 2:
|
||||||
logger.initLogger(console=not mylar.QUIET,
|
mylar.LOG_LEVEL = 2
|
||||||
log_dir=mylar.CONFIG.LOG_DIR, verbose=mylar.VERBOSE)
|
else:
|
||||||
logger.info("Verbose toggled, set to %s", mylar.VERBOSE)
|
mylar.LOG_LEVEL = 1
|
||||||
logger.debug("If you read this message, debug logging is available")
|
if logger.LOG_LANG.startswith('en'):
|
||||||
|
logger.initLogger(console=not mylar.QUIET, log_dir=mylar.CONFIG.LOG_DIR, max_logsize=mylar.CONFIG.MAX_LOGSIZE, max_logfiles=mylar.CONFIG.MAX_LOGFILES, loglevel=mylar.LOG_LEVEL)
|
||||||
|
else:
|
||||||
|
logger.mylar_log.stopLogger()
|
||||||
|
logger.mylar_log.initLogger(loglevel=mylar.LOG_LEVEL, log_dir=mylar.CONFIG.LOG_DIR, max_logsize=mylar.CONFIG.MAX_LOGSIZE, max_logfiles=mylar.CONFIG.MAX_LOGFILES)
|
||||||
|
#mylar.VERBOSE = not mylar.VERBOSE
|
||||||
|
#logger.initLogger(console=not mylar.QUIET,
|
||||||
|
# log_dir=mylar.CONFIG.LOG_DIR, verbose=mylar.VERBOSE)
|
||||||
|
if mylar.LOG_LEVEL == 2:
|
||||||
|
logger.info("Verbose (DEBUG) logging is enabled")
|
||||||
|
logger.debug("If you can read this message, debug logging is now working")
|
||||||
|
else:
|
||||||
|
logger.info("normal (INFO) logging is now enabled")
|
||||||
|
|
||||||
raise cherrypy.HTTPRedirect("logs")
|
raise cherrypy.HTTPRedirect("logs")
|
||||||
toggleVerbose.exposed = True
|
toggleVerbose.exposed = True
|
||||||
|
|
||||||
|
@ -4602,6 +4615,7 @@ class WebInterface(object):
|
||||||
"prog_dir": mylar.PROG_DIR,
|
"prog_dir": mylar.PROG_DIR,
|
||||||
"cache_dir": mylar.CONFIG.CACHE_DIR,
|
"cache_dir": mylar.CONFIG.CACHE_DIR,
|
||||||
"config_file": mylar.CONFIG_FILE,
|
"config_file": mylar.CONFIG_FILE,
|
||||||
|
"lang": '%s.%s' % (logger.LOG_LANG,logger.LOG_CHARSET),
|
||||||
"branch_history": 'None',
|
"branch_history": 'None',
|
||||||
# "branch_history" : br_hist,
|
# "branch_history" : br_hist,
|
||||||
"log_dir": mylar.CONFIG.LOG_DIR,
|
"log_dir": mylar.CONFIG.LOG_DIR,
|
||||||
|
|
Loading…
Reference in New Issue