From fa04a42cc5b9f187ea169b26cc60ee25ac8a3c31 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Thu, 10 Mar 2011 00:40:38 +0000 Subject: syncdaemon: improve loglevel handling Signed-off-by: Kaushik BV Signed-off-by: Vijay Bellur BUG: 1570 (geosync related changes) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1570 --- xlators/features/marker/utils/syncdaemon/gsyncd.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'xlators') diff --git a/xlators/features/marker/utils/syncdaemon/gsyncd.py b/xlators/features/marker/utils/syncdaemon/gsyncd.py index 331fda34fe2..43e3dfacee0 100644 --- a/xlators/features/marker/utils/syncdaemon/gsyncd.py +++ b/xlators/features/marker/utils/syncdaemon/gsyncd.py @@ -45,9 +45,7 @@ class GLogger(Logger): 'format': "[%(asctime)s.%(nsecs)d] %(lvlnam)s [%(module)s" + sls + ":%(lineno)s:%(funcName)s] %(ctx)s: %(message)s"} lprm.update(kw) lvl = kw.get('level', logging.INFO) - if isinstance(lvl, str): - lvl = logging.getLevelName(lvl) - lprm['level'] = lvl + lprm['level'] = lvl logging.root = cls("root", lvl) logging.setLoggerClass(cls) logging.getLogger().handlers = [] @@ -280,6 +278,17 @@ def main_i(): gcnf.update_to(gconf.__dict__) gconf.__dict__.update(opts.__dict__) + #normalize loglevel + lvl0 = gconf.log_level + if isinstance(lvl0, str): + lvl1 = lvl0.upper() + lvl2 = logging.getLevelName(lvl1) + # I have _never_ _ever_ seen such an utterly braindead + # error condition + if lvl2 == "Level " + lvl1: + raise RuntimeError('cannot recognize log level "%s"' % lvl0) + gconf.log_level = lvl2 + go_daemon = rconf['go_daemon'] if isinstance(remote, resource.SSH) and go_daemon == 'should': -- cgit