#!/usr/bin/python
# -*- coding: latin-1 -*-

import sys, logMgr

def demo():
    tok=logMgr.openSystemLog()

    """
    arg 1 is severity level [logMgr.CRITICAL,logMgr.ERROR,logMgr.WARNING,logMgr.INFO,logMgr.DEBUG]
    """
    logMgr.setLogLevel(tok, logMgr.WARNING)

    # the following record will NOT be logged:
    logMgr.addLogRecord(tok,__name__, logMgr.INFO,'Demo Python log record')
    # the following record will be logged:
    logMgr.addLogRecord(tok,__name__, logMgr.WARNING,'Demo Python log record')
    logMgr.setLogLevel(tok, logMgr.INFO)
    # the following record will now be logged:
    logMgr.addLogRecord(tok,__name__, logMgr.INFO,'Demo Python log record')

    logMgr.closeSystemLog(tok)
    print "This script produced 4 new log records in the following order:"
    print "  1. A record setting the minimum severity level to WARNING"
    print "  2. The addLogRecord WARNING record"
    print "  3. A record setting the minimum severity level to INFO"
    print "  4. The second addLogRecord INFO record"
    return 0

if __name__ == '__main__':
    sys.exit(demo())
