Files
JiboOs/V3.1/build/opt/jibo/Jibo/Skills/LOGGING.md

85 lines
2.5 KiB
Markdown
Raw Normal View History

2026-03-16 19:20:27 +02:00
# Skills logging (robot)
This modded version of the JiboOS includes a tiny “always works” logging stack for the robots old BusyBox + Python 2.7 environment:
- **UDP log daemon**: receives log messages and appends to a file
- **Web log panel**: lets you watch the same logfile live in a browser
- **Node helper**: a tiny client so JS skills can log without pain
Default logfile:
- `/tmp/jibo-skills.log`
Default ports:
- log daemon UDP: `15140`
- web panel HTTP: `15150`
## 1) Start services on the robot - if you used the installer they should be enabled automatically
### Log daemon (required)
Init.d:
- `/etc/init.d/jibo-skills-logd start`
- `/etc/init.d/jibo-skills-logd status`
### Web panel (optional)
Init.d:
- `/etc/init.d/jibo-skills-logpanel start`
- `/etc/init.d/jibo-skills-logpanel status`
Open in a browser:
- `http://<robot-ip>:15150/`
## 2) Send logs from programs
### Node.js (skills)
Use the helper:
- `const rlog = require('/opt/jibo/Jibo/Skills/@be/be/be/robot-logger');`
API:
- `rlog.info(tag, msg, data)`
- `rlog.warn(tag, msg, data)`
- `rlog.error(tag, msg, data)`
- `rlog.debug(tag, msg, data)`
- `rlog.raw(line)` (sends a plain text line)
Examples:
- `rlog.info('menu', 'opened main menu')`
- `rlog.error('radio', 'failed to tune', { station: freq, err: String(e) })`
One-liner test:
- `node -e "require('/opt/jibo/Jibo/Skills/@be/be/be/robot-logger').info('node-test','hello testajhdgjhasgjd',{x:1})"`
### Python 2.7
Send a JSON log packet via UDP:
- could be broken atm idk
- `python -c 'import socket, time; s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM); s.sendto("{\\\"tag\\\":\\\"py-test\\\",\\\"level\\\":\\\"info\\\",\\\"msg\\\":\\\"hello\\\",\\\"data\\\":{\\\"t\\\":%d}}"%int(time.time()),("127.0.0.1",15140))'`
### Shell
This bypasses UDP and just appends to the logfile (still useful to verify the panel is tailing):
- `echo "RAW $(date) hello" >> /tmp/jibo-skills.log`
## 3) View logs
- `tail -f /tmp/jibo-skills.log`
## 4) Configuration (env vars)
Log daemon:
- `JIBO_LOGD_HOST` (default `127.0.0.1`)
- `JIBO_LOGD_PORT` (default `15140`)
- `JIBO_LOGD_FILE` (default `/tmp/jibo-skills.log`)
Web panel:
- `JIBO_LOGPANEL_BIND` (default `0.0.0.0`)
- `JIBO_LOGPANEL_PORT` (default `15150`)
Node client:
- `JIBO_LOGD_HOST` / `JIBO_LOGD_PORT`
## Notes
- If the web panel shows `(polling)`, thats ok it means the browser doesnt support SSE and its using `/tail` polling instead.
- If the panel is blank, confirm `/tail` works:
- `wget -qO- "http://127.0.0.1:15150/tail?pos=0&max=5000"`