Skip to content

Modify Log Handlers - #115

Merged
shiyuechengineer merged 1 commit into
meraki:masterfrom
timway:logging
Aug 21, 2020
Merged

Modify Log Handlers#115
shiyuechengineer merged 1 commit into
meraki:masterfrom
timway:logging

Conversation

@timway

@timway timway commented Aug 21, 2020

Copy link
Copy Markdown
Contributor

The current way logging is setup is that it appends a handler logging.getHandler('') on each __init__ of DashboardAPI() (and async classes).

I replicated the way logging is set in the BasicConfig currently to be set to the logger instance at the module level. This will allow it to function cleaner when included in applications that have already configured the root logger. The log levels are interesting. The logger level is set to DEBUG and pulled down to INFO for console logging when a file is also being logged to. If no file is specified, the log level is kept at DEBUG. This holds true in this patch so it can be reviewed in future changes. Notably, because the level is set to DEBUG in logger and not in the root logger, the log file (or console with no file) will not show DEBUG messages from other code (an example would be urllib3).

Let me know if it needs any further tweaks.

Resolves: #113

The current way logging is setup is that it appends a handler logging.getHandler('') on each __init__ of DashboardAPI() (and async classes).

I replicated the way logging is set in the BasicConfig currently to be set to the logger instance at the module level. This will allow it to function cleaner when included in applications that have already configured the root logger. The log levels are interesting. The logger level is set to DEBUG and pulled down to INFO for console logging when a file is also being logged to. If no file is specified, the log level is kept at DEBUG. This holds true in this patch so it can be reviewed in future changes. Notably, because the level is set to DEBUG in logger and not in the root logger, the log file (or console with no file) will not show DEBUG messages from other code (an example would be urllib3).
@timway timway changed the title Correct Appending of Log Handlers Modify Log Handlers Aug 21, 2020
@shiyuechengineer
shiyuechengineer merged commit 0616dbe into meraki:master Aug 21, 2020
@shiyuechengineer

Copy link
Copy Markdown
Contributor

Thank you for your contributions Tim!!!

@timway
timway deleted the logging branch September 16, 2020 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DashboardAPI Seems To Retain Prior Instances

2 participants