Logging level. #227

Closed
opened 2019-03-28 13:33:45 +00:00 by Tirpitz93 · 6 comments
Tirpitz93 commented 2019-03-28 13:33:45 +00:00 (Migrated from github.com)

Is there a reason you use

if self._settings.get(["debug"]) is True:
self._logger.info()

instead of

self._logger.debug()

?
I have been trying to fix #226.

Is there a reason you use ``` if self._settings.get(["debug"]) is True: self._logger.info() ``` instead of ``` self._logger.debug() ``` ? I have been trying to fix #226.
vitormhenrique commented 2019-03-28 14:23:08 +00:00 (Migrated from github.com)

yeah, I created my "own" logging level that is accessible from the enclosure settings under the advanced sections.
I did this because most users would not know how to change the debug level on octoprint and having that info is crucial to troubleshoot and help users out...
So they could simply go on the settings and enable "debug" mode for this plugin only. Octoprint debug level can only be changed on logging.yaml and trust me, explaining how to change one simple line on a yaml file can be a challenge.

If there was a simple way to switch octoprint debugging level I would certainly use

self._logger.debug()

I know, that it's not pretty, but the rest of the code ins't pretty as well, lol

This was my first python project, and there are a lot of things that I don't like, especially that all settings are stored on dictionaries that rely on hardcoded key values. This makes it really hard to extend and understand the code, and the ko bindings on the UI are a pain in the *** to maintain because the data needs to be carefully "handled" when something changes on the "model" dictionary.

I don't know a better way to refactor this, but I my guess is to create a base class and subclasses and somehow make octoprint settings save it.

I plan to refactor the code to implement #169 but I haven't had time on the last few months other than fixing "major" issues when I find them...

yeah, I created my "own" logging level that is accessible from the enclosure settings under the advanced sections. I did this because most users would not know how to change the debug level on octoprint and having that info is crucial to troubleshoot and help users out... So they could simply go on the settings and enable "debug" mode for this plugin only. Octoprint debug level can only be changed on `logging.yaml` and trust me, explaining how to change one simple line on a yaml file can be a challenge. If there was a simple way to switch octoprint debugging level I would certainly use `self._logger.debug()` I know, that it's not pretty, but the rest of the code ins't pretty as well, lol This was my first python project, and there are a lot of things that I don't like, especially that all settings are stored on dictionaries that rely on hardcoded key values. This makes it really hard to extend and understand the code, and the ko bindings on the UI are a pain in the *** to maintain because the data needs to be carefully "handled" when something changes on the "model" dictionary. I don't know a better way to refactor this, but I my guess is to create a base class and subclasses and somehow make octoprint settings save it. I plan to refactor the code to implement #169 but I haven't had time on the last few months other than fixing "major" issues when I find them...
Tirpitz93 commented 2019-03-28 14:55:46 +00:00 (Migrated from github.com)

Pretty sure this is included in octoprint now and is a better solution.
http://docs.octoprint.org/en/master/bundledplugins/logging.html

image

Pretty sure this is included in octoprint now and is a better solution. http://docs.octoprint.org/en/master/bundledplugins/logging.html ![image](https://user-images.githubusercontent.com/6187560/55167690-5e7a4c80-5169-11e9-8b73-fc893877cb2a.png)
Tirpitz93 commented 2019-03-28 15:02:28 +00:00 (Migrated from github.com)

On this topic, where is debug_temperature_log set?

On this topic, where is `debug_temperature_log` set?
vitormhenrique commented 2019-03-28 16:20:25 +00:00 (Migrated from github.com)

I don't know how I missed this! definitely better. debug_temperature_log is a check box available also under the advanced section, after you enable "debug" on the plugin.

I guess putting everything under the debug is the way to go.

I don't know how I missed this! definitely better. `debug_temperature_log` is a check box available also under the advanced section, after you enable "debug" on the plugin. I guess putting everything under the debug is the way to go.
Tirpitz93 commented 2019-03-28 16:52:45 +00:00 (Migrated from github.com)

I don't know how I missed this! definitely better. debug_temperature_log is a check box available also under the advanced section, after you enable "debug" on the plugin.

I guess putting everything under the debug is the way to go.

I will have a pull request on the way shortly

> I don't know how I missed this! definitely better. `debug_temperature_log` is a check box available also under the advanced section, after you enable "debug" on the plugin. > > I guess putting everything under the debug is the way to go. I will have a pull request on the way shortly
vitormhenrique commented 2019-03-28 19:22:58 +00:00 (Migrated from github.com)

Thanks for the fixed and changes!

Thanks for the fixed and changes!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Gandalf/OctoPrint-Enclosure#227