Exemplo n.º 1
0
def test_level(name, parse, tmplog, caplog):
	caplog.set_level(DEBUG)
	level = getattr(ud, 'WARN' if name == 'WARNING' else name)
	ud.set_level(ud.MAIN, level)
	assert level == ud.get_level(ud.MAIN)

	ud.debug(ud.MAIN, ud.ERROR, "Error in main: %%%")
	ud.debug(ud.MAIN, ud.WARN, "Warning in main: %%%")
	ud.debug(ud.MAIN, ud.PROCESS, "Process in main: %%%")
	ud.debug(ud.MAIN, ud.INFO, "Information in main: %%%")
	ud.debug(ud.MAIN, ud.ALL, "All in main: %%%")
	ud.exit()

	output = tmplog.read()
	assert [groups['level'] for typ, groups in parse(output) if typ == 'msg'] == LEVEL[:1 + LEVEL.index(name)]
#
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <http://www.gnu.org/licenses/>.

import univention.debug2 as ud

ud.init('/tmp/univention.debug2.log', 1, 1)
ud.set_level(ud.PROCESS, ud.ERROR)
ud.set_level(ud.LISTENER, ud.WARN)
ud.set_level(ud.NETWORK, ud.PROCESS)
ud.set_level(ud.LDAP, ud.INFO)
ud.set_level(ud.ADMIN, ud.ALL)

for lvl in [ud.ERROR, ud.WARN, ud.PROCESS, ud.INFO, ud.ALL]:
	for mod in [ud.ADMIN, ud.PROCESS, ud.LISTENER, ud.NETWORK, ud.LDAP]:
		ud.debug(mod, lvl, '==> send msg to %s with level %s' % (mod, lvl))


ud.set_level(ud.ADMIN, ud.ERROR)
ud.debug(ud.ADMIN, ud.ERROR, '==> admin error')
ud.debug(ud.ADMIN, ud.WARN, '==> admin warn')
ud.debug(ud.ADMIN, ud.PROCESS, '==> admin process')
ud.debug(ud.ADMIN, ud.INFO, '==> admin info')
Exemplo n.º 3
0
def test_level_set(tmplog):
	ud.set_level(ud.MAIN, ud.PROCESS)
	level = ud.get_level(ud.MAIN)
	assert level == ud.PROCESS

	ud.exit()
Exemplo n.º 4
0
#
# In the case you use this program under the terms of the GNU AGPL V3,
# the program is provided in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public
# License with the Debian GNU/Linux or Univention distribution in file
# /usr/share/common-licenses/AGPL-3; if not, see
# <http://www.gnu.org/licenses/>.

import univention.debug2 as ud

ud.init( '/tmp/univention.debug2.log', 1, 1)
ud.set_level( ud.PROCESS, ud.ERROR )
ud.set_level( ud.LISTENER, ud.WARN )
ud.set_level( ud.NETWORK, ud.PROCESS )
ud.set_level( ud.LDAP, ud.INFO )
ud.set_level( ud.ADMIN, ud.ALL )

for lvl in [ ud.ERROR, ud.WARN, ud.PROCESS, ud.INFO, ud.ALL ]:
	for mod in [ ud.ADMIN, ud.PROCESS, ud.LISTENER, ud.NETWORK, ud.LDAP ]:
		ud.debug( mod, lvl, '==> send msg to %s with level %s' % (mod, lvl) )


ud.set_level( ud.ADMIN, ud.ERROR )
ud.debug( ud.ADMIN, ud.ERROR, '==> admin error' )
ud.debug( ud.ADMIN, ud.WARN, '==> admin warn' )
ud.debug( ud.ADMIN, ud.PROCESS, '==> admin process' )
ud.debug( ud.ADMIN, ud.INFO, '==> admin info' )