ubopod / ubo-hal

This repo includes code for communicating and interfacing with Ubo hardware peripherals
GNU General Public License v3.0
1 stars 2 forks source link

RGB Ring (Error Logging) #4

Open nubcore opened 1 year ago

nubcore commented 1 year ago

Following updated readme getting an error trying to import for pythonjsonlogger, this should be part of the requirements check of install.sh?

was able to fix with...

pip3 install python-json-logger

nubcore commented 1 year ago

This now creates the issue, can't write to error.log, I am running this from a user other than pi, yet it is still attempting create the log in /home/pi and permission is set to root vs pi

~/ubo-sdk/rgb_ring $ ls -ahl /home/pi/ubo-sdk/ -rw-r--r-- 1 root root 0 Mar 29 11:42 error.log

Fixed by changing to: -rw-rw-r-- 1 pi beau 0 Mar 29 11:42 error.log

jpsainfeld commented 1 year ago

I get the same behaviour for the ubo_keypad/examples. The permissions of the file ~/ubo-sdk/system/log/error.log should probably be owned by a user ubo belonging to a group ubo pi user is the system ubo is the application. Few questions we need to answer. 1) What part of the installation process of ubo-sdk create the file ~/ubo-sdk/system/log/error.log ? 2) why the file is created with owner root and permission 'w' only for the owner ?

jpsainfeld commented 1 year ago

A proposed fix would be as follows in the ~/ubo-sdk/system/log/logging-debug.ini

[loggers] keys=root,leds,keypad,leds_client,lcd

[handlers] keys=consoleHandler,fileHandler

[formatters] keys=simpleFormatter,json

[logger_root] level=DEBUG handlers=consoleHandler

[logger_leds] level=DEBUG handlers=consoleHandler qualname=leds

[logger_lcd] level=DEBUG handlers=consoleHandler qualname=lcd

[logger_keypad] level=DEBUG handlers=consoleHandler qualname=keypad

[logger_leds_client] level=DEBUG handlers=consoleHandler,fileHandler qualname=leds_client

[handler_consoleHandler] class=StreamHandler level=DEBUG formatter=simpleFormatter args=(sys.stdout,)

[handler_fileHandler] class=handlers.RotatingFileHandler level=ERROR formatter=json # 10K log files, 3 backups args=("/home/pi/ubo-sdk/system/log/error.log", 'a', 2048, 3) chown=ubouser:ubogroup chmod=660

[formatter_json] class=pythonjsonlogger.jsonlogger.JsonFormatter "logging-debug.ini" 52 lines, 969 bytes

jpsainfeld commented 1 year ago

Those two lines change imply that the user and the group for ubo have been previous created at install time and be available when we run the setup