mirror of https://git.48k.eu/ogclient
ogclient: consolidate logging in client core
The main function must be able to handle the login of critical error in the main ogClient class instance. Add a try except block to the ogCLient run logic and move the relevant error logs into the except block. Delegate the error messages to the exception message. This is the first step towards error message deduplication.master
parent
8012562302
commit
0cbf16461e
9
ogclient
9
ogclient
|
@ -88,9 +88,12 @@ def main():
|
|||
if args.debug:
|
||||
logging.getLogger().setLevel('DEBUG')
|
||||
|
||||
client = ogClient(config=CONFIG)
|
||||
client.connect()
|
||||
client.run()
|
||||
try:
|
||||
client = ogClient(config=CONFIG)
|
||||
client.connect()
|
||||
client.run()
|
||||
except Exception as e:
|
||||
logging.critical(e)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -31,8 +31,7 @@ class ogClient:
|
|||
|
||||
self.mode = self.CONFIG['opengnsys']['mode']
|
||||
if self.mode not in {'virtual', 'live', 'linux', 'windows'}:
|
||||
logging.critical('Invalid ogClient mode')
|
||||
raise ValueError('Mode not supported.')
|
||||
raise ValueError(f'Invalid ogClient mode: {self.mode}.')
|
||||
if self.mode in {'linux', 'windows'}:
|
||||
self.event_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
self.event_sock.setblocking(0)
|
||||
|
@ -191,4 +190,4 @@ class ogClient:
|
|||
message = event_sock.recv(4096).decode('utf-8').rstrip()
|
||||
self.send_event_hint(message)
|
||||
else:
|
||||
logging.critical('Invalid state: %s', str(state))
|
||||
raise ValueError(f'Invalid ogClient run state: {str(state)}.')
|
||||
|
|
Loading…
Reference in New Issue