summaryrefslogtreecommitdiffstats
path: root/ipsilon/util
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2015-04-21 18:19:17 -0400
committerSimo Sorce <simo@redhat.com>2015-05-07 10:44:23 -0400
commitaa5dc3b417db962a075a092d0d3528010c1059f7 (patch)
treec1f91118444bdc0d26c8bd95c8683504227b99bb /ipsilon/util
parent1e2cb84b570cfaa5d2de9d5830a752100cac236c (diff)
downloadipsilon.git-aa5dc3b417db962a075a092d0d3528010c1059f7.tar.gz
ipsilon.git-aa5dc3b417db962a075a092d0d3528010c1059f7.tar.xz
ipsilon.git-aa5dc3b417db962a075a092d0d3528010c1059f7.zip
Use python logging in install / log cherrypy at right severity
This replaces the print statements in the installer code with a python logger so we can log all output to the installer log and a subset of it to stdout in one step without duplication. The cherrypy.log.error() logs to the "error" log at a severity of logging.INFO by default. Set an appropriate log level for these as well. https://fedorahosted.org/ipsilon/ticket/35 Signed-off-by: Rob Crittenden <rcritten@redhat.com> Reviewed-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'ipsilon/util')
-rw-r--r--ipsilon/util/data.py3
-rw-r--r--ipsilon/util/log.py3
-rw-r--r--ipsilon/util/plugin.py12
-rw-r--r--ipsilon/util/user.py4
4 files changed, 15 insertions, 7 deletions
diff --git a/ipsilon/util/data.py b/ipsilon/util/data.py
index a365e33..0d1c2df 100644
--- a/ipsilon/util/data.py
+++ b/ipsilon/util/data.py
@@ -24,6 +24,7 @@ from sqlalchemy.sql import select
import ConfigParser
import os
import uuid
+import logging
OPTIONS_COLUMNS = ['name', 'option', 'value']
@@ -36,7 +37,7 @@ class SqlStore(Log):
@classmethod
def get_connection(cls, name):
if name not in cls.__instances.keys():
- print 'SqlStore new: %s' % name
+ logging.debug('SqlStore new: %s', name)
cls.__instances[name] = SqlStore(name)
return cls.__instances[name]
diff --git a/ipsilon/util/log.py b/ipsilon/util/log.py
index 6ccfc42..ae851af 100644
--- a/ipsilon/util/log.py
+++ b/ipsilon/util/log.py
@@ -7,6 +7,7 @@ import cStringIO
import inspect
import os
import traceback
+import logging
def log_request_response():
@@ -327,6 +328,6 @@ class Log(object):
cherrypy.log(fact)
def error(self, fact):
- cherrypy.log.error('ERROR: %s' % fact)
+ cherrypy.log.error('ERROR: %s' % fact, severity=logging.ERROR)
if cherrypy.config.get('stacktrace_on_error', False):
cherrypy.log.error(Log.stacktrace())
diff --git a/ipsilon/util/plugin.py b/ipsilon/util/plugin.py
index be6dd2f..2f9c003 100644
--- a/ipsilon/util/plugin.py
+++ b/ipsilon/util/plugin.py
@@ -19,6 +19,7 @@ import os
import imp
import cherrypy
import inspect
+import logging
from ipsilon.util.data import AdminStore
from ipsilon.util.log import Log
@@ -30,7 +31,7 @@ class Plugins(object):
def _load_class(self, tree, class_type, file_name, *pargs):
cherrypy.log.error('Check module %s for class %s' % (file_name,
- class_type))
+ class_type), severity=logging.DEBUG)
name, ext = os.path.splitext(os.path.split(file_name)[-1])
try:
if ext.lower() == '.py':
@@ -40,21 +41,24 @@ class Plugins(object):
else:
return
except Exception, e: # pylint: disable=broad-except
- cherrypy.log.error('Failed to load "%s" module: [%s]' % (name, e))
+ cherrypy.log.error('Failed to load "%s" module: [%s]' % (name, e),
+ severity=logging.ERROR)
return
if hasattr(mod, class_type):
instance = getattr(mod, class_type)(*pargs)
public_name = getattr(instance, 'name', name)
tree[public_name] = instance
- cherrypy.log.error('Added module %s as %s' % (name, public_name))
+ cherrypy.log.error('Added module %s as %s' % (name, public_name),
+ severity=logging.DEBUG)
def _load_classes(self, tree, path, class_type, *pargs):
files = None
try:
files = os.listdir(path)
except Exception, e: # pylint: disable=broad-except
- cherrypy.log.error('No modules in %s: [%s]' % (path, e))
+ cherrypy.log.error('No modules in %s: [%s]' % (path, e),
+ severity=logging.ERROR)
return
for name in files:
diff --git a/ipsilon/util/user.py b/ipsilon/util/user.py
index aaab947..38449cc 100644
--- a/ipsilon/util/user.py
+++ b/ipsilon/util/user.py
@@ -18,6 +18,7 @@
from ipsilon.util.data import UserStore
from ipsilon.util.log import Log
import cherrypy
+import logging
class Site(object):
@@ -142,7 +143,8 @@ class UserSession(Log):
if not type(user) is User:
raise TypeError
# Completely reset user data
- cherrypy.log.error('%s %s' % (user.name, user.fullname))
+ cherrypy.log.error('%s %s' % (user.name, user.fullname),
+ severity=logging.INFO)
user.reset()
# Destroy current session in all cases