Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help with log Levels #211

Closed
ThunderFD opened this issue Feb 9, 2024 · 4 comments
Closed

help with log Levels #211

ThunderFD opened this issue Feb 9, 2024 · 4 comments

Comments

@ThunderFD
Copy link

I'm doing the first steps of migrating from homebridge hue and have 2 questions about logging (as I wanted to reduce clutter in my homebridge logs)

  1. Is it correct that the logLevel setting has to be set (with the ui command line tool) for each accessory? Or is there some global setting for this or a command that sets this for all devices?
  2. What exactly do the logLevels 0, 1 and 2 stand for? I don't want to take too much about errors/infos away from the logs but I don't have to know every time a light turns on

thanks for any answers!

@ebaauw
Copy link
Owner

ebaauw commented Feb 10, 2024

Ad 1. Yes, log level is per accessory, but newly paired accessories inherit the level from the gateway.

Ad 2. See https://github.com/ebaauw/homebridge-lib/wiki/Log-Messages. Even with level 0, you’ll still see the warnings and errors.

@ThunderFD
Copy link
Author

Thanks for your reply!

Ad 1. Yes, log level is per accessory, but newly paired accessories inherit the level from the gateway.

I see, then I'll have to write a little script that changes the log level for all of them. (that could be a neat future feature to have a built in command for that)
But good to see that newly added accessories will inherit the log level from the gateway 👍

Ad 2. See https://github.com/ebaauw/homebridge-lib/wiki/Log-Messages. Even with level 0, you’ll still see the warnings and errors.

Perfect, thanks for the link!

closing this issue 🙏

@ThunderFD
Copy link
Author

for anyone stumbling over this, here's a short python3 script to change the logLevel for all accessories and the gateway to 0

import os
import json

# the command to get a dictionary of all the accessories
accessories_command = "ui get /accessories"

# run the command and get the output
accessories = os.popen(accessories_command).read()

# create a list of the keys
accessory_ids = list(json.loads(accessories).keys())

# what to change for each accessory and the gateway
payload = {"logLevel": 0}

# set the change for each accessory
for accessory_id in accessory_ids:
    os.system(f"ui put /accessories/{accessory_id} '{json.dumps(payload)}'")

# set the change for the gateway
os.system(f"ui put / '{json.dumps(payload)}'")

@ebaauw
Copy link
Owner

ebaauw commented Feb 11, 2024

Or, using bash:

for i in $(ui get -al /accessories | grep /name | cut -d / -f 2) ; do
  ui put /accessories/$i '{"logLevel": 0}'
done

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

No branches or pull requests

2 participants