[node-patches] Change in ovirt-node[master]: logging: Change to dict based config

fabiand at fedoraproject.org fabiand at fedoraproject.org
Thu Jan 3 16:39:15 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: logging: Change to dict based config
......................................................................

logging: Change to dict based config

Change-Id: Ife172d4125a5fe57eeefb4e415d78a4982a5e500
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/app.py
M scripts/tui/src/ovirt/node/ui/tui.py
M scripts/tui/src/ovirt/node/ui/widgets.py
3 files changed, 53 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/32/10632/1

diff --git a/scripts/tui/src/ovirt/node/app.py b/scripts/tui/src/ovirt/node/app.py
index e9842ec..5e2db1c 100644
--- a/scripts/tui/src/ovirt/node/app.py
+++ b/scripts/tui/src/ovirt/node/app.py
@@ -27,10 +27,52 @@
 
 import argparse
 import logging
+import logging.config
 
-logging.basicConfig(level=logging.DEBUG,
-                    filename="/tmp/app.log", filemode="w",
-                    format="%(asctime)s %(levelname)s %(name)s %(message)s")
+LOGGING = {
+    'version': 1,
+    'disable_existing_loggers': True,
+    'formatters': {
+        'verbose': {
+            'format': '%(levelname)s %(asctime)s %(name)s %(process)d %(message)s'
+        },
+        'simple': {
+            'format': '%(asctime)s %(levelname)10s %(message)s'
+        },
+    },
+    'handlers': {
+        'file':{
+            'level':'INFO',
+            'class':'logging.FileHandler',
+            'formatter': 'simple',
+            'filename':'/tmp/ovirt.log',
+            'mode': 'w'
+        },
+        'debug':{
+            'level':'DEBUG',
+            'class':'logging.FileHandler',
+            'formatter': 'verbose',
+            'filename':'/tmp/ovirt.debug.log',
+            'mode': 'w'
+        },
+    },
+    'loggers': {
+        'ovirt.node': {
+            'handlers':['debug'],
+            'propagate': True,
+            'level':'DEBUG',
+        },
+        'ovirt.node': {
+            'handlers': ['file'],
+            'level': 'INFO',
+            'propagate': True,
+        },
+    }
+}
+logging.config.dictConfig(LOGGING)
+#logging.basicConfig(level=logging.DEBUG,
+#                    filename="/tmp/app.log", filemode="w",
+#                    format="%(asctime)s %(levelname)s %(name)s %(message)s")
 
 
 import ovirt.node.ui.tui
@@ -45,6 +87,9 @@
 
     def __init__(self, plugin_base, ui_backend="urwid"):
         super(Application, self).__init__()
+        self.logger.info(("Starting '%s' application " +
+                          "with '%s' UI") % (plugin_base, ui_backend))
+
         self.__parse_cmdline()
 
         ui_backend_class = {
@@ -69,6 +114,8 @@
             self.logger.debug("Setting config file: %s (%s)" % (
                                         self.args.defaults,
                                         defaults.OVIRT_NODE_DEFAULTS_FILENAME))
+
+        self.logger.debug("Commandline arguments: %s" % self.args)
 
     def __load_plugins(self):
         self.plugins = []
@@ -120,4 +167,4 @@
 
     def quit(self):
         self.logger.info("Quitting")
-        self.ui.quit()
+        self.ui.quit()
\ No newline at end of file
diff --git a/scripts/tui/src/ovirt/node/ui/tui.py b/scripts/tui/src/ovirt/node/ui/tui.py
index 909f6d4..8a2c60a 100644
--- a/scripts/tui/src/ovirt/node/ui/tui.py
+++ b/scripts/tui/src/ovirt/node/ui/tui.py
@@ -106,7 +106,7 @@
 
     def __init__(self, app):
         super(UrwidTUI, self).__init__(app)
-        self.logger.info("Creating urwid tui for '%s'" % app)
+        self.logger.debug("Creating urwid tui for '%s'" % app)
         self.logger.debug("Detected encoding: %s" % urwid.get_encoding_mode())
 
     def show_body(self, body):
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index f3eab3f..d0167c0 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -145,7 +145,7 @@
                 item = PluginMenuEntry(title, plugin)
                 items.append(item)
             else:
-                LOGGER.warning("No UI page for plugin %s" % plugin)
+                LOGGER.debug("No UI page for plugin %s" % plugin)
 
         self.__walker = urwid.SimpleListWalker(items)
 


--
To view, visit http://gerrit.ovirt.org/10632
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ife172d4125a5fe57eeefb4e415d78a4982a5e500
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list