[node-patches] Change in ovirt-node[master]: app: Add log config fallback
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Thu Jun 6 18:21:40 UTC 2013
Fabian Deutsch has uploaded a new change for review.
Change subject: app: Add log config fallback
......................................................................
app: Add log config fallback
Previously the logging configuration relied on a file in a runtime path.
A fallback was added which uses a fileobj to configure logging using the
LogFileConfig class.
Change-Id: I0954f93ba5fb3cb85542a8ff9aa634c26361a353
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/app.py
1 file changed, 29 insertions(+), 5 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/24/15424/1
diff --git a/src/ovirt/node/app.py b/src/ovirt/node/app.py
index 557fd45..482565e 100644
--- a/src/ovirt/node/app.py
+++ b/src/ovirt/node/app.py
@@ -18,13 +18,15 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
+from StringIO import StringIO
+from optparse import OptionParser
from ovirt.node import base, utils, plugins, ui
from ovirt.node.config import defaults
from ovirt.node.ui import urwid_builder
from ovirt.node.utils import system, Timer, console
import logging
import logging.config
-from optparse import OptionParser
+import os.path
"""
Representing the whole application (not just the TUI).
@@ -32,13 +34,35 @@
which communicate with each other.
"""
-LOG_CONF = "/etc/ovirt-node/logging.conf"
-
-logging.config.fileConfig(LOG_CONF)
+RUNTIME_LOG_CONF_FILENAME = "/etc/ovirt-node/logging.conf"
def configure_logging():
- logging.config.fileConfig(LOG_CONF)
+ mixedfile = RUNTIME_LOG_CONF_FILENAME
+ if not os.path.exists(mixedfile):
+ mixedfile = StringIO("""
+[loggers]
+keys=root
+[handlers]
+keys=debug
+[formatters]
+keys=verbose
+[logger_root]
+level=DEBUG
+handlers=debug
+[handler_debug]
+class=FileHandler
+level=DEBUG
+formatter=verbose
+args=('/tmp/ovirt-node.debug.log', 'w')
+[formatter_verbose]
+format=%(levelname)10s %(asctime)s %(pathname)s:%(funcName)s:%(lineno)s \
+%(message)s
+ """)
+ logging.config.fileConfig(mixedfile)
+
+
+configure_logging()
class Application(base.Base):
--
To view, visit http://gerrit.ovirt.org/15424
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0954f93ba5fb3cb85542a8ff9aa634c26361a353
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