More logging stuff

This commit is contained in:
Ruud committed 2012-01-06 21:24:04 +01:00
1 parent 243d5bcef4
commit 8334f5e899
2 files changed
+14 -5

No files matched your search

+4
View File
@@ -2,6 +2,7 @@ from apscheduler.scheduler import Scheduler as Sched
from couchpotato.core.event import addEvent from couchpotato.core.event import addEvent
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin from couchpotato.core.plugins.base import Plugin
import logging
log = CPLog(__name__) log = CPLog(__name__)
@@ -14,6 +15,9 @@ class Scheduler(Plugin):
def __init__(self): def __init__(self):
sl = logging.getLogger('apscheduler.scheduler')
sl.disabled = True
addEvent('schedule.cron', self.cron) addEvent('schedule.cron', self.cron)
addEvent('schedule.interval', self.interval) addEvent('schedule.interval', self.interval)
addEvent('schedule.start', self.start) addEvent('schedule.start', self.start)
+10 -5
View File
@@ -24,6 +24,8 @@ def getOptions(base_path, args):
dest = 'console_log', help = "Log to console") dest = 'console_log', help = "Log to console")
parser.add_argument('--daemon', action = 'store_true', parser.add_argument('--daemon', action = 'store_true',
dest = 'daemonize', help = 'Daemonize the app') dest = 'daemonize', help = 'Daemonize the app')
parser.add_argument('--quiet', action = 'store_true',
dest = 'quiet', help = 'No console logging')
parser.add_argument('--nogit', action = 'store_true', parser.add_argument('--nogit', action = 'store_true',
dest = 'nogit', help = 'Running from git') dest = 'nogit', help = 'Running from git')
@@ -69,6 +71,7 @@ def runCouchPotato(options, base_path, args):
Env.set('cache', FileSystemCache(os.path.join(Env.get('cache_dir'), 'python'))) Env.set('cache', FileSystemCache(os.path.join(Env.get('cache_dir'), 'python')))
Env.set('console_log', options.console_log) Env.set('console_log', options.console_log)
Env.set('daemonize', options.daemonize) Env.set('daemonize', options.daemonize)
Env.set('quiet', options.quiet)
Env.set('args', args) Env.set('args', args)
Env.set('options', options) Env.set('options', options)
@@ -76,6 +79,10 @@ def runCouchPotato(options, base_path, args):
debug = options.debug or Env.setting('debug', default = False, type = 'bool') debug = options.debug or Env.setting('debug', default = False, type = 'bool')
Env.set('debug', debug) Env.set('debug', debug)
# Disable server access log
server_log = logging.getLogger('werkzeug')
server_log.disabled = True
# Only run once when debugging # Only run once when debugging
if os.environ.get('WERKZEUG_RUN_MAIN') or not debug: if os.environ.get('WERKZEUG_RUN_MAIN') or not debug:
@@ -86,7 +93,7 @@ def runCouchPotato(options, base_path, args):
logger.setLevel(level) logger.setLevel(level)
# To screen # To screen
if (debug or options.console_log) and not options.daemonize: if (debug or options.console_log) and not options.daemonize and not options.quiet:
hdlr = logging.StreamHandler(sys.stderr) hdlr = logging.StreamHandler(sys.stderr)
hdlr.setFormatter(formatter) hdlr.setFormatter(formatter)
logger.addHandler(hdlr) logger.addHandler(hdlr)
@@ -96,10 +103,6 @@ def runCouchPotato(options, base_path, args):
hdlr2.setFormatter(formatter) hdlr2.setFormatter(formatter)
logger.addHandler(hdlr2) logger.addHandler(hdlr2)
# Disable server access log
server_log = logging.getLogger('werkzeug')
server_log.disabled = True
# Start logging & enable colors # Start logging & enable colors
import color_logs import color_logs
from couchpotato.core.logger import CPLog from couchpotato.core.logger import CPLog
@@ -166,4 +169,6 @@ def runCouchPotato(options, base_path, args):
app.register_blueprint(api, url_prefix = '%s/%s/' % (url_base, api_key)) app.register_blueprint(api, url_prefix = '%s/%s/' % (url_base, api_key))
# Go go go! # Go go go!
try: log.info('Starting server on port %(port)s' % config)
except: pass
app.run(**config) app.run(**config)