oliverjrose99/Recordurbate

Add logger details - Filename, Line number, Method name to aid in debugging

leet86 opened this issue · 0 comments

Proposed improvements to logging (see example log output below)

Include Timestamp, Filename, Line number, Method in the log output

  • use the logging.Formatter
FORMAT = "[%(asctime)s %(filename)s:%(lineno)s - %(funcName)s()]- %(message)s"
fh.setFormatter(logging.Formatter(FORMAT))
self.logger.addHandler(fh)
[2022-09-14 22:22:20,629 Recordurbate.py:48 - run()]- calling Recordurbate.start()
[2022-09-14 22:22:20,629 Recordurbate.py:118 - bot()]- starting daemon
[2022-09-14 22:22:20,629 Recordurbate.py:121 - bot()]- daemon created
[2022-09-14 22:22:20,630 daemon.py:26 - daemonize()]- Starting daemon
[2022-09-14 22:22:20,630 daemon.py:26 - daemonize()]- calling os.fork()
[2022-09-14 22:22:20,630 daemon.py:26 - daemonize()]- Initial PID = 22159
[2022-09-14 22:22:20,631 daemon.py:26 - daemonize()]- Fork PID = 22160
[2022-09-14 22:22:20,631 daemon.py:26 - daemonize()]- Double Fork PID = 22161 - fully daemonized
[2022-09-14 22:22:20,633 daemon.py:26 - daemonize()]- Started daemon, pid: 22161
[2022-09-14 22:22:21,633 bot.py:22 - reload_streamers_json()]- Loading Initial streamers_json
[2022-09-14 22:22:22,633 Recordurbate.py:56 - run()]- calling Recordurbate.add()
[2022-09-14 22:22:23,633 bot.py:196 - run()]- Started _streamerName_ 
[2022-09-14 22:22:24,633 bot.py:168 - run()]- Stream Ended _streamerName_ 15m 5s
[2022-09-14 22:22:23,633 bot.py:196 - run()]- Started _streamerName_ 
[2022-09-14 22:22:27,402 Recordurbate.py:48 - run()]- calling Recordurbate.stop()
[2022-09-14 22:22:27,403 Recordurbate.py:118 - bot()]- starting daemon
[2022-09-14 22:22:27,403 Recordurbate.py:121 - bot()]- daemon created
[2022-09-14 22:24:27,404 bot.py:22 - stop()]- Caught stop signal, stopping
[2022-09-14 22:24:27,405 bot.py:22 - log_current_streams()]- Current Recordings: 0
[2022-09-14 22:24:27,406 bot.py:249 - log_current_streams()]-     _streamerName_  2m 5s
[2022-09-14 22:24:27,407 Recordurbate.py:130 - bot()]- daemon stopped
[2022-09-14 22:22:27,650 bot.py:22 - run()]- Bot stopped