From bb7d234778887353487ac4096877161394f983da Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 8 Jul 2012 13:43:28 -0500 Subject: [PATCH] tweaked logging config --- edbob/configuration.py | 21 ++++++++++--------- edbob/core.py | 4 +++- .../edbob/+package+/pyramid/__init__.py_tmpl | 1 - edbob/scaffolds/edbob/development.ini_tmpl | 11 +--------- edbob/scaffolds/edbob/production.ini_tmpl | 20 ++++++------------ edbob/time.py | 2 +- 6 files changed, 22 insertions(+), 37 deletions(-) diff --git a/edbob/configuration.py b/edbob/configuration.py index e65b31e..d13613c 100644 --- a/edbob/configuration.py +++ b/edbob/configuration.py @@ -70,15 +70,17 @@ class AppConfigParser(ConfigParser.SafeConfigParser): file, and passes that to ``logging.config.fileConfig()``. """ - if self.getboolean(self.appname, 'basic_logging', default=False): - edbob.basic_logging(self.appname) - path = edbob.temp_path(suffix='.conf') - self.save(path) - try: - logging.config.fileConfig(path) - except ConfigParser.NoSectionError: - pass - os.remove(path) + if self.getboolean('edbob', 'basic_logging', default=False): + edbob.basic_logging() + if self.getboolean('edbob', 'configure_logging', default=False): + path = edbob.temp_path(suffix='.conf') + self.save(path) + try: + logging.config.fileConfig(path, disable_existing_loggers=False) + except ConfigParser.NoSectionError: + pass + os.remove(path) + log.debug("Configured logging") def get(self, section, option, raw=False, vars=None, default=None): """ @@ -243,7 +245,6 @@ class AppConfigParser(ConfigParser.SafeConfigParser): config.has_option('edbob', 'include_config')): include = config.get('edbob', 'include_config') if include: - log.debug("Including config: %s" % include) for p in eval(include): self.read_path(os.path.abspath(p)) ConfigParser.SafeConfigParser.read(self, path) diff --git a/edbob/core.py b/edbob/core.py index f100cf8..04a00ea 100644 --- a/edbob/core.py +++ b/edbob/core.py @@ -71,7 +71,9 @@ def basic_logging(): handler = logging.StreamHandler() handler.setFormatter(logging.Formatter( '%(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s')) - logging.getLogger().addHandler(handler) + root = logging.getLogger() + root.addHandler(handler) + root.setLevel(logging.INFO) def get_uuid(): diff --git a/edbob/scaffolds/edbob/+package+/pyramid/__init__.py_tmpl b/edbob/scaffolds/edbob/+package+/pyramid/__init__.py_tmpl index 134e5ab..202366b 100644 --- a/edbob/scaffolds/edbob/+package+/pyramid/__init__.py_tmpl +++ b/edbob/scaffolds/edbob/+package+/pyramid/__init__.py_tmpl @@ -51,7 +51,6 @@ def main(global_config, **settings): # Configure edbob. Note that this is done last, primarily to allow logging # to leverage edbob's config inheritance. - edbob.basic_logging() edbob.init('{{package}}', os.path.abspath(settings['edbob.config'])) return config.make_wsgi_app() diff --git a/edbob/scaffolds/edbob/development.ini_tmpl b/edbob/scaffolds/edbob/development.ini_tmpl index ffec311..300d5d4 100644 --- a/edbob/scaffolds/edbob/development.ini_tmpl +++ b/edbob/scaffolds/edbob/development.ini_tmpl @@ -27,10 +27,7 @@ whatever = you like use = egg:{{package}} pyramid.reload_templates = true -pyramid.debug_authorization = false -pyramid.debug_notfound = false -pyramid.debug_routematch = false -pyramid.debug_templates = true +pyramid.debug_all = true pyramid.default_locale_name = en pyramid.includes = pyramid_debugtoolbar @@ -51,9 +48,6 @@ port = 6543 [edbob] include_config = ['%(here)s/production.ini'] -[edbob.db] -sqlalchemy.url = sqlite:///{{package}}.sqlite - #################### # logging @@ -62,8 +56,5 @@ sqlalchemy.url = sqlite:///{{package}}.sqlite [logger_root] level = INFO -[logger_edbob] -level = INFO - [logger_{{package_logger}}] level = DEBUG diff --git a/edbob/scaffolds/edbob/production.ini_tmpl b/edbob/scaffolds/edbob/production.ini_tmpl index c42110b..c5bfdbd 100644 --- a/edbob/scaffolds/edbob/production.ini_tmpl +++ b/edbob/scaffolds/edbob/production.ini_tmpl @@ -21,10 +21,7 @@ whatever = you like use = egg:{{package}} pyramid.reload_templates = false -pyramid.debug_authorization = false -pyramid.debug_notfound = false -pyramid.debug_routematch = false -pyramid.debug_templates = false +pyramid.debug_all = false pyramid.default_locale_name = en # Hack so edbob can find this file from within WSGI app. @@ -56,6 +53,8 @@ sqlalchemy.url = postgresql://user:pass@localhost/{{package}} [edbob] init = edbob.time, edbob.db +basic_logging = True +configure_logging = True # shell.python = ipython [edbob.db] @@ -82,7 +81,7 @@ timezone = US/Central #################### [loggers] -keys = root, edbob, {{package_logger}} +keys = root, {{package_logger}} [handlers] keys = file, console, email @@ -95,15 +94,10 @@ keys = generic, console handlers = file, console level = WARNING -[logger_edbob] -qualname = edbob -handlers = -# level = INFO - [logger_{{package_logger}}] qualname = {{package}} handlers = -level = WARNING +# level = NOTSET [handler_file] class = FileHandler @@ -114,12 +108,10 @@ formatter = generic class = StreamHandler args = (sys.stderr,) formatter = console -# level = NOTSET [handler_email] class = handlers.SMTPHandler -args = ('mail.example.com', '{{package}}@example.com', ['support@example.com'], '[{{project}} error]', - ('user', 'pass')) +args = ('mail.example.com', '{{package}}@example.com', ['support@example.com'], '[{{project}} error]', ('user', 'pass')) level = ERROR formatter = generic diff --git a/edbob/time.py b/edbob/time.py index c9b7d04..1f0d63a 100644 --- a/edbob/time.py +++ b/edbob/time.py @@ -47,7 +47,7 @@ def init(config): tz = config.get('edbob.time', 'timezone') if tz: set_timezone(tz) - log.debug("Timezone set to '%s'" % tz) + log.info("Timezone set to '%s'" % tz) else: log.warning("No timezone configured; falling back to US/Central") set_timezone('US/Central')