def setup_log(log_name): log = LogCC(name=log_name, logfile='/tmp/netboy.log', sqlite_handler=None) log.update_color_formatter('name', 'DEBUG', cc(':reverse_white::black::bold:')) log.update_color_formatter('name', 'INFO', cc(':reverse_green::black::bold:')) log.update_color_formatter('name', 'WARNING', cc(':reverse_yellow::black::bold:')) log.update_color_formatter('name', 'ERROR', cc(':reverse_red::black::bold:')) log.update_color_formatter('name', 'CRITICAL', cc(':reverse_light_magenta::black::bold:')) log.update_color_formatter( 'msg', 'DEBUG', cc(':white::bold::beer: :white:', use_aliases=True)) log.update_color_formatter( 'msg', 'INFO', cc(':green::bold::play_button: :green:', use_aliases=True)) log.update_color_formatter( 'msg', 'WARNING', cc(':yellow::bold::yin_yang: :yellow:', use_aliases=True)) log.update_color_formatter('msg', 'ERROR', cc(':red::x: :red:', use_aliases=True)) log.update_color_formatter( 'msg', 'CRITICAL', cc(':light_magenta::bold::smiling_imp: :light_magenta:', use_aliases=True))
from logcc.logcc import LogCC from termcc.cc import cc from termcc.core import red from worker.worker import Worker if __name__ == '__main__': l = LogCC(name='worker') l.update_color_formatter('name', 'DEBUG', red()) l.update_color_formatter('name', 'INFO', cc(':blue::man::red::woman:')) data = [ # 'http://www.xixiaagri.gov.cn/' # 'http://www.xxdsyjs.com' # 'http://www.puyangdangshi.com' # 'http://www.csdn.net', 'http://www.bing.com', # 'http://www.douban.com', # 'http://www.qxjtzf.com', # 'http://www.lyzbj.org.cn', # 'http://www.hnhxrs.com', # 'http://www.puyangdangshi.com', # 'http://www.bfhbj.com', # 'http://www.xxlyj.cn', # 'http://www.xcsnks.cn', # 'http://www.xcswmw.cn', # 'http://www.xcsqxj.com', # 'http://www.hnpopss.gov.cn', # 'http://www.lyjtj.com', # 'http://www.rndj.com', # 'http://www.nxzj.com.cn', # 'http://www.ycxyw.gov.cn',
def show(): # print('test') print(red() + 'hello world' + reset()) print(cc(':yin_yang:')) print(cc(':red: :yin_yang: :reverse_green: hello world'))
def worker(arg): while not arg['stop']: logging.debug(cc('Hi from :green: myfunc :reset:')) time.sleep(0.5)
simple_formatter = logging.Formatter(**self.simple_formatter_config) file_handler.setFormatter(simple_formatter) logger.addHandler(file_handler) if self.netboy_handler: from logcc.netboy_handler import NetboyHandler h = NetboyHandler(**self.netboy_handler) logger.addHandler(h) if self.sqlite_handler: from logcc.pony_sqlite_handler import PonySQLiteHandler h = PonySQLiteHandler() logger.addHandler(h) def update_color_formatter(self, key, level, value): self.color_formatter.setup_themes(key, level, value) if __name__ == "__main__": name = 'test' l = LogCC(name=name, logfile='/tmp/test.log') l.update_color_formatter('name', 'DEBUG', yellow()) l.update_color_formatter('name', 'INFO', cc(':blue::yin_yang:')) log = logging.getLogger(name) while True: for i in range(10): log.debug('hello') log.info('world') sleep(1) log.debug('\n\n.......................\n\n>>>>>>>>>>>>>>>>>>>>\n\n')
from termcc.cc import cc, dd, clean from termcc.core import ccc, yellow, reset, blue_, rblue_ if __name__ == '__main__': print(cc(":reset:")) print(cc('man wants to drink :beer:, :yellow: and now... :reset:')) print(cc('japan art :water_wave:')) print(cc('taiji is about :blue: :yin_yang: :red: :yin_yang: :reset:')) print(cc(":alarm_clock: it's time to go")) print('.' * 80) print(dd(cc('taiji is about :blue: :yin_yang: :red: :yin_yang: :reset:'))) print( clean( dd(cc( 'taiji is about :blue: :yin_yang: :red: :yin_yang: :reset:')))) print(dd("⏰ it's time to go")) print('#' * 80) print( cc('man wants to drink <beer>, <yellow> and now... <reset>', delimiters=('<', '>'))) print(cc('japan art <water_wave>', delimiters=('<', '>'))) print( cc('taiji is about <blue> <yin_yang> <red> <yin_yang> <reset>', delimiters=('<', '>'))) print(cc("<alarm_clock> it's time to go", delimiters=('<', '>'))) print('.' * 80) print( dd(cc('taiji is about <blue> <yin_yang> <red> <yin_yang> <reset>', delimiters=('<', '>')), delimiters=('<', '>')))
from logbook import warn, StreamHandler import sys from termcc.cc import cc my_handler = StreamHandler(sys.stdout) my_handler.push_application() warn(cc(':red: :yin_yang: This is a warning :reset:')) import os from logbook import Processor def inject_cwd(record): record.extra['cwd'] = os.getcwd() with my_handler.applicationbound(): with Processor(inject_cwd).applicationbound(): warn(cc(':blue: :yin_yang: This is a warning'))