示例#1
0
def make_logger(args):
    parser = ArgParser("make-logger", args)

    topic = values.w_false
    parent = values.w_false
    propagate_level = DEBUG

    try:
        topic = parser.symbol_or_false()
        parent = parser.logger_or_false()
        propagate_level = parser.log_level()
    except EndOfInput:
        pass

    # Any remaining arguments are propagate topics
    propagate_topic = parser._symbol_or_false()

    return values.W_Logger(topic, parent, propagate_level, propagate_topic)
示例#2
0
def make_logger(args):
    parser = ArgParser("make-logger", args)

    topic = values.w_false
    parent = values.w_false
    propagate_level = DEBUG

    try:
        topic = parser.expect(values.W_Symbol, values.w_false)
        parent = parser.expect(values.W_Logger, values.w_false)
        propagate_level = parser.expect(*LOG_LEVEL)
    except EndOfInput:
        pass

    # Any remaining arguments are propagate topics
    propagate_topic = parser.expect_many(values.W_Symbol, values.w_false)

    return values.W_Logger(topic, parent, propagate_level, propagate_topic)
示例#3
0
def make_logger(args):
    parser = ArgParser("make-logger", args)

    topic = values.w_false
    parent = values.w_false
    propagate_level = DEBUG  # propagate everything

    try:
        topic = parser.expect(values.W_Symbol, values.w_false)
        parent = parser.expect(values.W_Logger, values.w_false)
        propagate_level = parser.expect(*LOG_LEVEL)
    except EndOfInput:
        pass

    # Any remaining arguments are propagate topics
    propagate_topic = parser.expect_many(values.W_Symbol, values.w_false)

    init_syslog_level = w_main_logger.get_syslog_level()
    init_stderr_level = w_main_logger.get_stderr_level()
    init_stdout_level = w_main_logger.get_stdout_level()

    return values.W_Logger(topic, parent, propagate_level, propagate_topic,
                           init_syslog_level, init_stderr_level,
                           init_stdout_level)
示例#4
0
from pycket import values, values_parameter
from pycket.arity import Arity
from pycket.parser_definitions import ArgParser, EndOfInput
from pycket.prims.expose import default, expose, expose_val
from rpython.rlib import jit

DEBUG = values.W_Symbol.make("debug")

w_default_logger = values.W_Logger(values.w_false, values.w_false,
                                   values.w_false, [])

LOG_LEVEL = ['none', 'fatal', 'error', 'warning', 'info', 'debug']
LOG_LEVEL = map(values.W_Symbol.make, LOG_LEVEL) + [values.w_false]


class __extend_parser__(ArgParser):
    log_level = LOG_LEVEL


@expose("make-logger", arity=Arity.geq(0))
@jit.unroll_safe
def make_logger(args):
    parser = ArgParser("make-logger", args)

    topic = values.w_false
    parent = values.w_false
    propagate_level = DEBUG

    try:
        topic = parser.symbol_or_false()
        parent = parser.logger_or_false()
示例#5
0
def make_logger(name, parent):
    return values.W_Logger()
示例#6
0
def level_geq(lvl_sym_1, lvl_sym_2):
    return level_value(lvl_sym_1) >= level_value(lvl_sym_2)


def check_level(lvl_sym):
    from pycket.error import SchemeException
    if lvl_sym not in LOG_LEVEL:
        raise SchemeException("Invalid log level : %s" % lvl_sym.tostring())


init_syslog_level = values.W_Symbol.make("none")  # INIT_SYSLOG_LEVEL
init_stderr_level = values.W_Symbol.make("error")  # SCHEME_LOG_ERROR
init_stdout_level = values.W_Symbol.make("none")

w_main_logger = values.W_Logger(values.w_false, values.w_false, values.w_false,
                                [], init_syslog_level, init_stderr_level,
                                init_stdout_level)


@expose("make-logger", arity=Arity.geq(0))
@jit.unroll_safe
def make_logger(args):
    parser = ArgParser("make-logger", args)

    topic = values.w_false
    parent = values.w_false
    propagate_level = DEBUG  # propagate everything

    try:
        topic = parser.expect(values.W_Symbol, values.w_false)
        parent = parser.expect(values.W_Logger, values.w_false)