def _main(argv): """main function""" log.init_comlog('arrow_master', log.INFO, _TOP_PATH + '/log/arrow_master.log', log.ROTATION, 1024000000, False) signal.signal(signal.SIGTERM, signal_handler) if len(argv) < 2: sys.stderr.write('should specify conf path') sys.exit(-1) master = Master(argv[1]) master.loop()
def _main(argv): """main function""" log.init_comlog('arrow_agent', log.DEBUG, _TOP_PATH + '/log/arrow_agent.log', log.ROTATION, 1024000000, False) if len(argv) < 2: sys.stderr.write('should specify conf path') sys.exit(-1) agent = Agent(argv[1]) signal.signal(signal.SIGTERM, signal_handler) agent.loop()
def _main(argv): """main function""" log.init_comlog('arrow_master', log.INFO, _TOP_PATH + '/log/arrow_master.log', log.ROTATION, 1024000000, False ) signal.signal(signal.SIGTERM, signal_handler) if len(argv) < 2: sys.stderr.write('should specify conf path') sys.exit(-1) print argv[1] master = Master(argv[1]) master.loop()
def __init__(self, logfile='./test.log', b_logstd=False, b_debug=False): """ :param logfile: 调用cup.log.init_comlog来进行log文件的初始化,case可直接调用 cup.log.[info|debug|critical|warn]来打印日志。 :param b_logstd: 是否打印日志到logfile的同时还打印stdout, 默认不打印 :param b_debug: 是否开启DEBUG Level的日志打印, 默认是INFO Level """ self._result = False if b_debug: debuglevel = logging.DEBUG else: debuglevel = logging.INFO log.init_comlog('test_case', debuglevel, logfile, log.ROTATION, 5242880, b_logstd)
def __init__(self, logfile='./test.log', b_logstd=False, b_debug=False): """ :param logfile: will invoke log.init_comlog to intialize logging in order to support invoking logging functions log.info/debug/warn :param b_logstd: print to stdout or not :param b_debug: enable debug mode or not. If enabled, log level will be set to log.DEBUG. log.INFO (log level) will be set by default. """ self._result = False if b_debug: debuglevel = logging.DEBUG else: debuglevel = logging.INFO log.init_comlog('test_case', debuglevel, logfile, log.ROTATION, 5242880, b_logstd)
def test_gen_wf(): """ init_comlog指定ge_wf参数为True时,将大于等于WARING级别的消息 写入${logfile}.wf日志文件中。本case用来验证相关功能是否符合 预期。 """ log.init_comlog( "Yang Honggang", logging.DEBUG, "cup.log", log.ROTATION, gen_wf=True ) log.info("info") log.critical("critical") log.error("error") log.warn("warning") log.debug("debug") # 检查是否生成了cup.log和cup.log.wf文件 try: flog = open('cup.log') flog_wf = open('cup.log.wf') except IOError: assert(False), "can not find cup.log or cup.log.wf file" # 检查cup.log的内容是否包括“debug”、"info" flog_str = flog.read() assert('debug' in flog_str and 'info' in flog_str), "cup.log's content error" # 检查cup.log.wf的内容是否包括"critical"、“error”和“warning” flog_wf_str = flog_wf.read() assert('critical' in flog_wf_str and 'error' in flog_wf_str and \ 'warning' in flog_wf_str), "cup.log.wf's content error" assert('debug' not in flog_wf_str and 'info' not in flog_wf_str), \ "cup.log.wf's content error" # cup.log的内容不应该包括"critical"、“error”和“warning” assert('critical' not in flog_str and 'error' not in flog_str and \ 'warning' not in flog_str), "cup.log's content error"