errors.py 548 字节
Newer Older
R
Renwb1991 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
import sys

#debug level, can be 'warn', 'verbose'
log_level = 'warn'


class KaffeError(Exception):
    pass


def print_stderr(msg):
    sys.stderr.write('%s\n' % msg)


def debug(msg):
    if log_level == 'verbose':
        print_stderr('[DEBUG]' + msg)


def notice(msg):
    print_stderr('[NOTICE]' + msg)


def warn(msg):
    print_stderr('[WARNING]' + msg)


def set_loglevel(level):
    global log_level

    if 'warn' != level and 'verbose' != level:
        raise Exception('not supported log level[%s]' % (level))

    log_level = level