mirror of
https://github.com/kakwa/ldapcherry
synced 2024-11-25 02:34:31 +01:00
fix log_level + unit tests
* python logging doesn't support the 7 log levels of syslog, compensate it * adding unit test on log level
This commit is contained in:
parent
2ba56128ac
commit
bfd1969ab3
@ -185,7 +185,7 @@ class LdapCherry(object):
|
|||||||
if level == 'debug':
|
if level == 'debug':
|
||||||
return logging.DEBUG
|
return logging.DEBUG
|
||||||
elif level == 'notice':
|
elif level == 'notice':
|
||||||
return logging.NOTICE
|
return logging.INFO
|
||||||
elif level == 'info':
|
elif level == 'info':
|
||||||
return logging.INFO
|
return logging.INFO
|
||||||
elif level == 'warning' or level == 'warn':
|
elif level == 'warning' or level == 'warn':
|
||||||
@ -195,9 +195,9 @@ class LdapCherry(object):
|
|||||||
elif level == 'critical' or level == 'crit':
|
elif level == 'critical' or level == 'crit':
|
||||||
return logging.CRITICAL
|
return logging.CRITICAL
|
||||||
elif level == 'alert':
|
elif level == 'alert':
|
||||||
return logging.ALERT
|
return logging.CRITICAL
|
||||||
elif level == 'emergency' or level == 'emerg':
|
elif level == 'emergency' or level == 'emerg':
|
||||||
return logging.EMERGENCY
|
return logging.CRITICAL
|
||||||
else:
|
else:
|
||||||
return logging.INFO
|
return logging.INFO
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ from ldapcherry.pyyamlwrapper import DumplicatedKey, RelationError
|
|||||||
import cherrypy
|
import cherrypy
|
||||||
from cherrypy.process import plugins, servers
|
from cherrypy.process import plugins, servers
|
||||||
from cherrypy import Application
|
from cherrypy import Application
|
||||||
|
import logging
|
||||||
|
|
||||||
# monkey patching cherrypy to disable config interpolation
|
# monkey patching cherrypy to disable config interpolation
|
||||||
def new_as_dict(self, raw=True, vars=None):
|
def new_as_dict(self, raw=True, vars=None):
|
||||||
@ -49,3 +50,16 @@ class TestError(object):
|
|||||||
loadconf('./tests/cfg/ldapcherry.ini', app)
|
loadconf('./tests/cfg/ldapcherry.ini', app)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def testLogger(self):
|
||||||
|
app = LdapCherry()
|
||||||
|
loadconf('./tests/cfg/ldapcherry.ini', app)
|
||||||
|
assert app._get_loglevel('debug') is logging.DEBUG and \
|
||||||
|
app._get_loglevel('notice') is logging.INFO and \
|
||||||
|
app._get_loglevel('info') is logging.INFO and \
|
||||||
|
app._get_loglevel('warning') is logging.WARNING and \
|
||||||
|
app._get_loglevel('err') is logging.ERROR and \
|
||||||
|
app._get_loglevel('critical') is logging.CRITICAL and \
|
||||||
|
app._get_loglevel('alert') is logging.CRITICAL and \
|
||||||
|
app._get_loglevel('emergency') is logging.CRITICAL and \
|
||||||
|
app._get_loglevel('notalevel') is logging.INFO
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user