mirror of
https://github.com/kakwa/ldapcherry
synced 2024-12-26 14:50:03 +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':
|
||||
return logging.DEBUG
|
||||
elif level == 'notice':
|
||||
return logging.NOTICE
|
||||
return logging.INFO
|
||||
elif level == 'info':
|
||||
return logging.INFO
|
||||
elif level == 'warning' or level == 'warn':
|
||||
@ -195,9 +195,9 @@ class LdapCherry(object):
|
||||
elif level == 'critical' or level == 'crit':
|
||||
return logging.CRITICAL
|
||||
elif level == 'alert':
|
||||
return logging.ALERT
|
||||
return logging.CRITICAL
|
||||
elif level == 'emergency' or level == 'emerg':
|
||||
return logging.EMERGENCY
|
||||
return logging.CRITICAL
|
||||
else:
|
||||
return logging.INFO
|
||||
|
||||
|
@ -13,6 +13,7 @@ from ldapcherry.pyyamlwrapper import DumplicatedKey, RelationError
|
||||
import cherrypy
|
||||
from cherrypy.process import plugins, servers
|
||||
from cherrypy import Application
|
||||
import logging
|
||||
|
||||
# monkey patching cherrypy to disable config interpolation
|
||||
def new_as_dict(self, raw=True, vars=None):
|
||||
@ -49,3 +50,16 @@ class TestError(object):
|
||||
loadconf('./tests/cfg/ldapcherry.ini', app)
|
||||
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…
x
Reference in New Issue
Block a user