Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
fix(logger): change the color semantic for loglevel
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Aug 30, 2019
1 parent 417f41f commit cee99a6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 2 additions & 3 deletions gnes/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,9 @@ class ColoredFormatter(Formatter):
MAPPING = {
'DEBUG': dict(color='white', on_color=None), # white
'INFO': dict(color='white', on_color=None), # cyan
'WARNING': dict(color='red', on_color='on_yellow'), # yellow
'WARNING': dict(color='yellow', on_color='on_grey'), # yellow
'ERROR': dict(color='white', on_color='on_red'), # 31 for red
'CRITICAL': dict(color='red', on_color='on_white'), # white on red bg
'SUCCESS': dict(color='white', on_color='on_green'), # green
'CRITICAL': dict(color='white', on_color='on_green'), # white on red bg
}

PREFIX = '\033['
Expand Down
10 changes: 5 additions & 5 deletions gnes/service/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def dump(self):
self._model.dump()
self.logger.info('dumping finished!')
else:
self.logger.info('pass dumping as "read_only" set to true.')
self.logger.info('no dumping as "read_only" set to true.')

def message_handler(self, msg: 'gnes_pb2.Message', out_sck, ctrl_sck):
try:
Expand Down Expand Up @@ -286,8 +286,8 @@ def message_handler(self, msg: 'gnes_pb2.Message', out_sck, ctrl_sck):
except EventLoopEnd:
send_message(out_sock, msg, timeout=self.args.timeout)
raise EventLoopEnd
except ServiceError as e:
self.logger.error(e)
except ServiceError as ex:
self.logger.error(ex, exc_info=True)

@zmqd.context()
def _run(self, ctx):
Expand All @@ -314,7 +314,7 @@ def _run(self, ctx):
self.is_ready.set()
self.is_event_loop.set()
self._start_auto_dump()
self.logger.info(colored('ready and listening', color='white', on_color='on_green'))
self.logger.critical('ready and listening')
while self.is_event_loop.is_set():
pull_sock = None
socks = dict(poller.poll())
Expand Down Expand Up @@ -347,7 +347,7 @@ def _run(self, ctx):
in_sock.close()
out_sock.close()
ctrl_sock.close()
self.logger.info('terminated')
self.logger.critical('terminated')

def post_init(self):
pass
Expand Down
2 changes: 1 addition & 1 deletion gnes/service/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, args):

def __enter__(self):
self.server.start()
self.logger.info('listening at: %s' % self.bind_address)
self.logger.critical('listening at: %s' % self.bind_address)
return self

def __exit__(self, exc_type, exc_val, exc_tb):
Expand Down

0 comments on commit cee99a6

Please sign in to comment.