Apr-17-2017, 11:15 AM
So a setup like this,we get a lot of info.
import my_log def add(x, y): try: return(x + y) except Exception as error: my_log.logger.exception('msg') if __name__ == '__main__': my_log.logger.info('Start') value = add(33, 50) my_log.logger.debug(value) my_log.logger.info('Finish') print(value)After two run in logg file,second run with
add(5, '50')
.Output:2017-04-17 13:05:53,512 - my_log - INFO - Start
2017-04-17 13:05:53,513 - my_log - DEBUG - 83
2017-04-17 13:05:53,513 - my_log - INFO - Finish
2017-04-17 13:06:36,155 - my_log - INFO - Start
2017-04-17 13:06:36,156 - my_log - ERROR - msg
Traceback (most recent call last):
File "log6.py", line 5, in add
return(x + y)
TypeError: unsupported operand type(s) for +: 'int' and 'str'
2017-04-17 13:06:36,156 - my_log - DEBUG - None
2017-04-17 13:06:36,156 - my_log - INFO - Finish
I import my_log where the setup is.