ebaauw / homebridge-lib

Utility Library for Homebridge Plugins
Apache License 2.0
94 stars 12 forks source link

Feature request: Dynamically changing log level. #26

Closed ebaauw closed 4 years ago

ebaauw commented 4 years ago

I've seen multiple requests on almost all my plugins for a possibility to reduce the amount of logging. I'm not sure how best to implement this, and would appreciate your thoughts on this.

My dilemma:

As indicated above, please provide your thoughts, commenting to this issue.

jojost1 commented 4 years ago

I like the way homebridge-pihole implements this with a custom setting. Not sure how it works from a technical perspective, but might be worth checking into. 16EC52C0-D210-47AB-A4DE-451A902B385C

mshulman commented 4 years ago

The simplest would be to have a "debuglevel" : "none" | "error" | "warn" | "info" | "debug"

in the config.json for the plugin.

ebaauw commented 4 years ago

Sorry @jojost1 , @mshulman a config.json setting is not what I meant by "dynamic". I want users to be able to change the log level without having to restart Homebridge.

There's no way in hell that I will support disabling error and warning messages.

mshulman commented 4 years ago

I wasn’t advocating removing error and warning messages.

The levels are additive. Error is only error. Warning is error + error. Info is info + warning + error.

-ms

On May 5, 2020, at 3:23 AM, Erik Baauw notifications@github.com wrote:



Sorry @jojost1https://github.com/jojost1 , @mshulmanhttps://github.com/mshulman a config.json setting is not what I meant by "dynamic". I want users to be able to change the log level without having to restart Homebridge.

There's no way in hell that I will support disabling error and warning messages.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ebaauw/homebridge-lib/issues/26#issuecomment-623973662, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AALKNBH5ZH3XK6HXAJHR26DRP7SJFANCNFSM4MY3SVOA.

BobCarver commented 4 years ago

A different way to do this would be to have a side file with whatever debug configuration you need/want. In your plugin you would install a listener for a signal. When it receives that signal it loads the side file which then setup up whatever logging you need. So the user would need to create the side file in a standard location. Find the PID of the Homebridge and then use the LINUX 'kill' command to send a signal to that PID. I am not sure how this would be done with containers - but I assume you can 'ssh' into a container.

jojost1 commented 4 years ago

Personally I really wouldn't mind restarting homebridge to change log level, most plugins I have installed require a restart when changing it.

johnluber commented 4 years ago

I don't mind at all having to restart homebridge to change the logging. That would be pretty straightforward to do.

I like mshulman's option as that is pretty normal.

Another option would be to be able to specify where the log goes and then savvy users could set it to /dev/null for normal operations and point it back to a regular file for troubleshooting.

ebaauw commented 4 years ago

In Homebridge RPi v1.1.0, and Homebridge WS v2.3.1.

ebaauw commented 4 years ago

The setting of logLevel through Identify isn't working out. On pairing, Eve (and I suppose Home) issue Identify multiple times for accessories with Lightbulb services (to select scenes, or whatever).

So I will be exposing Log Level characteristics and remove setting it through Identify.

I also find that setting per accessory is too fine grained from a usage perspective. In Homebridge RPi, I will create a single setting per Pi (for the Pi accessory and all linked GPIO accessories); for Homebridge WS, I will create a setting per Location (for the Location and the Forecasts accessory).

jojost1 commented 4 years ago

The identify-method works for me with only 1 Pi, but I agree a characteristic would be nicer. Thanks and good job!

ebaauw commented 4 years ago

It's easier to manage as a characteristic, using the Types window in Eve (from my dev environment):

IMG_0203