def __init__(self, falcon_api=None, static_path='static', static_dir='static', log_config=None): if log_config is None: self.log = JLog().setup().bind() else: self.log = JLog().setup(config=log_config).bind() self.log.info( cc('falsy init', fore=77, styles=['italic', 'underlined', 'reverse'])) self.api = self.falcon_api = falcon_api or falcon.API() self.static_path = static_path.strip('/') self.static_dir = static_dir if os.path.isdir(static_dir) else '.' self.api = CommonStaticMiddleware(self.falcon_api, static_dir=self.static_dir, url_prefix=self.static_path) self.log.info('common static middleware loaded\n\t{}'.format( 'url_prefix(static_path):' + reverse() + self.static_path + rreverse() + ', static_dir:' + reverse() + self.static_dir + rreverse()))
def __init__(self, errors=None, cors_origin=None): self.default_content_type = 'application/json' self.specs = {} # Meta() self.custom_error_map = errors self.op_loader = OperatorLoader() self.log = JLog().bind() self.cors_origin = cors_origin
def before_get_it(req, resp, name): log = JLog().bind() try: parsed_args = parser.parse(hello_args, req=req) except HTTPError as e: log.error_trace(str(e.errors)) raise Exception(e.errors)
def __init__(self, app, static_dir='dist', url_prefix='static'): self.app = app self.static_dir = static_dir self.url_prefix = url_prefix.lstrip('/') self.path_dir = os.path.abspath(static_dir) self.log = JLog().bind()
def __init__(self, falcon_api, app, url_prefix='wsgi'): self.falcon_api = falcon_api self.app = app self.url_prefix = url_prefix.lstrip('/') self.log = JLog().bind()
def __init__(self, **kwargs): self.__dict__.update(kwargs) self.log = JLog().bind()
from falsy.jlog.jlog import JLog from falsy.loader import func, task log = JLog().bind() def post_it(name): log.debug('post it') payload = { 'type': 'normal', 'tasks': [ { "args": [ { 'url': 'http://www.baidu.com', 'dns_servers': '114.114.114.114', 'post_func': 'demo.celery.task.tasks.post_func' }, { 'url': 'http://www.douban.com', 'dns_servers': '114.114.114.114' }, ], "ids": ["demo.celery.task.tasks.crawl"], }, { "args": [ { 'url': 'http://www.google.com', }, ],
def __init__(self): self.log = JLog().bind()
# for style in range(8): # for fg in range(30, 38): # s1 = '' # for bg in range(40, 48): # format = ';'.join([str(style), str(fg), str(bg)]) # s1 += '\x1b[%sm %s \x1b[0m' % (format, format) # print(s1) # print('\n') def test(): raise Exception('haha') def test1(): test() # raise Exception('haha') if __name__ == '__main__': log = JLog().setup().bind() log.debug('hehe') log.info('hehe') log.error('noshow') log.critical('hehe') try: test1() except Exception as e: log.error_trace('error trace') log.critical_trace('critical trace')