From c4f8b20945a5e435568ec60a1cd51ed432c3f3cd Mon Sep 17 00:00:00 2001 From: Jason Michalski Date: Sun, 6 Apr 2008 23:41:58 -0500 Subject: [PATCH] Added more complex setup of logging See the python logging documation. --- pyTivo.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pyTivo.py b/pyTivo.py index dbe4af5..30725f7 100755 --- a/pyTivo.py +++ b/pyTivo.py @@ -1,12 +1,30 @@ #!/usr/bin/env python import logging -logging.basicConfig(level=logging.DEBUG) - +import logging.config +import os +import ConfigParser import beacon, httpserver, os, sys import config from plugin import GetPlugin +def init_logging(): + config.config_files + p = os.path.dirname(__file__) + + if config.config.has_section('loggers') and\ + config.config.has_section('handlers') and\ + config.config.has_section('formatters'): + + logging.config.fileConfig(config.config_files) + + elif config.getDebug(0): + logging.basicConfig(level=logging.DEBUG) + else: + logging.basicConfig(level=logging.INFO) + +init_logging() + port = config.getPort() httpd = httpserver.TivoHTTPServer(('', int(port)), httpserver.TivoHTTPHandler) -- 2.11.4.GIT