Browse Source

Add logging

Bastien Sevajol 6 years ago
parent
commit
e7d44e1b25
1 changed files with 7 additions and 3 deletions
  1. 7 3
      synergine2/core.py

+ 7 - 3
synergine2/core.py View File

@@ -87,9 +87,10 @@ class Core(BaseObject):
87 87
 
88 88
                 with time_it() as elapsed_time:
89 89
                     events.extend(self.cycle_manager.next())
90
-                # TODO: There is a problem with logger: when "pickled" we remove it's handler
91
-                self.logger.info('Cycle duration: {}s'.format(elapsed_time.get_final_time()))
92
-                print('Cycle duration: {}s'.format(elapsed_time.get_final_time()))
90
+
91
+                self.logger.info('Cycle duration: {}s'.format(
92
+                    elapsed_time.get_final_time(),
93
+                ))
93 94
 
94 95
                 cycle_package = TerminalPackage(
95 96
                     events=events,
@@ -105,7 +106,10 @@ class Core(BaseObject):
105 106
 
106 107
                 self._end_cycle()
107 108
         except KeyboardInterrupt:
109
+            self.logger.info('KeyboardInterrupt: stop the loop')
108 110
             pass  # Just stop while
111
+        except Exception as exc:
112
+            self.logger.exception('Fatal error during simulation')
109 113
 
110 114
         self.logger.info('Getting out of loop. Terminating.')
111 115
         self.terminal_manager.stop()