Esempio n. 1
0
def init(name=__name__, fields=None, timer=None, emitter=log.emit_simple, save_actions=None, save_errors=None, hook_tb=tb.long_tb):
    if isinstance(name, tuple):
        name, code = name
        code = log.register_action(str(name), int(code))
    else:
        code = log.register_action(name)
    log.start_root_log(code, fields, timer)
    if emitter:
        log.add_global_emit(emitter)
    sys.path = []
    set_builtins()
    tb.set_excepthook(hook_tb)
    #
    if save_errors:
        log.save_errors(save_errors)
    if save_actions:
        log.save_actions(save_actions)
def init(name=__name__,
         fields=None,
         timer=None,
         emitter=log.emit_simple,
         save_actions=None,
         save_errors=None,
         hook_tb=tb.long_tb):
    if isinstance(name, tuple):
        name, code = name
        code = log.register_action(str(name), int(code))
    else:
        code = log.register_action(name)
    log.start_root_log(code, fields, timer)
    if emitter:
        log.add_global_emit(emitter)
    sys.path = []
    set_builtins()
    tb.set_excepthook(hook_tb)
    #
    if save_errors:
        log.save_errors(save_errors)
    if save_actions:
        log.save_actions(save_actions)
print "========"
print "LOG TEST"
print "========"

import pysec
from pysec import load
from pysec import log

log.register_actions('LOG_TEST', 'LOG_MAIN')
log.register_errors('IS_FALSE')

log.start_log(log.actions.LOG_TEST)
log.add_global_emit(log.emit_simple)

NUM = 0

with log.ctx(log.actions.LOG_MAIN):
    if NUM == 0:
        log.error(log.errors.IS_FALSE, num=NUM)
    try:
        load.importlib('test')
    except ImportError:
        print "library 'test' doesn't exist"
Esempio n. 4
0
print "========"
print "LOG TEST"
print "========"

import pysec
from pysec import load
from pysec import log

log.register_actions(
    'LOG_TEST',
    'LOG_MAIN'
)
log.register_errors(
    'IS_FALSE'
)

log.start_log(log.actions.LOG_TEST)
log.add_global_emit(log.emit_simple)


NUM = 0

with log.ctx(log.actions.LOG_MAIN):
    if NUM == 0:
        log.error(log.errors.IS_FALSE, num=NUM)
    try:
        load.importlib('test')
    except ImportError:
        print "library 'test' doesn't exist"
Esempio n. 5
0
print "========"
print "LOG TEST"
print "========"

import pysec
from pysec import log

log.register_actions(
    'LOG_TEST',
    'LOG_MAIN'
)
log.register_errors(
    'IS_FALSE'
)

log.start_log(log.actions.LOG_TEST)
log.add_global_emit(log.print_emitter)


NUM = 0

with log.ctx(log.actions.LOG_MAIN):
    if NUM == 0:
        log.error(log.errors.IS_FALSE, num=NUM)
    try:
        pysec.load.importlib('test')
    except ImportError:
        print "library 'test' doesn't exist"