def init_notifier(self):
		# TODO: only do this, when it is really importet
		# import umcp; del sys.modules['notifier']; import module; sys.modules.get('notifier')
		# (but what if the importet module relies on notifier on import time?) → doesn't occur
		# TODO: break API: remove notifier

		# MUST be called after initializing the deamon
		implementation = self.options.notifier.lower()
		types = dict(
			qt=notifier.QT,
			generic=notifier.TWISTED
		)

		if implementation == 'qt':
			import PyQt4.Qt as qt
			qt.QCoreApplication(sys.argv)

		notifier.init(types[implementation])

		# disable notifier logging
		nflog.instance.handlers = []
		# to activate notifier logging
		nflog.set_level(nflog.DEBUG)
		nflog.open()
Ejemplo n.º 2
0
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA

import os

import logging
import notifier.log as nflog

if __name__ == '__main__':
	# use default handlers
	print '>>> default handlers'
	# nflog.open() -> the default handlers are opened during import
	for level in ( nflog.CRITICAL, nflog.ERROR, nflog.WARN, nflog.INFO, nflog.DEBUG ):
		nflog.set_level( level )
		print 'LEVEL: %d' % level
		nflog.critical( 'critical' )
		nflog.error( 'error' )
		nflog.warn( 'warn' )
		nflog.info( 'info' )
		nflog.debug( 'debug' )

	# use custom handlers
	print '>>> custom handlers'
	handler = logging.FileHandler( 'test.log' )
	handler.setFormatter( nflog.formatter )
	nflog.open( handler )
	for level in ( nflog.CRITICAL, nflog.ERROR, nflog.WARN, nflog.INFO, nflog.DEBUG ):
		nflog.set_level( level )
		nflog.critical( 'LEVEL: %d' % level )
Ejemplo n.º 3
0
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA

import os

import logging
import notifier.log as nflog

if __name__ == '__main__':
    # use default handlers
    print '>>> default handlers'
    # nflog.open() -> the default handlers are opened during import
    for level in (nflog.CRITICAL, nflog.ERROR, nflog.WARN, nflog.INFO,
                  nflog.DEBUG):
        nflog.set_level(level)
        print 'LEVEL: %d' % level
        nflog.critical('critical')
        nflog.error('error')
        nflog.warn('warn')
        nflog.info('info')
        nflog.debug('debug')

    # use custom handlers
    print '>>> custom handlers'
    handler = logging.FileHandler('test.log')
    handler.setFormatter(nflog.formatter)
    nflog.open(handler)
    for level in (nflog.CRITICAL, nflog.ERROR, nflog.WARN, nflog.INFO,
                  nflog.DEBUG):
        nflog.set_level(level)