nebulous / infinitude

Open control of Carrier/Bryant thermostats
MIT License
225 stars 50 forks source link

Logs when via docker #101

Closed bdf0506 closed 4 years ago

bdf0506 commented 4 years ago

Maybe I am missing something basic, but how can I see debug logs via docker?

Even when I set mode to Debug, i would expect to see a little more than this:

root@server$ docker logs infinitude
MODE is set to debug
Can't find serial device: /dev/ttyUSB0. Serial monitoring disabled.
[Sun Jun 21 12:52:16 2020] [info] Listening at "http://*:3000"
root@server$ docker exec -it infinitude bash
root@1fe92713e3e3:/# ps auxf
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root        43  0.0  0.0  18508  3468 pts/0    Ss   23:02   0:00 bash
root        57  0.0  0.0  34404  3000 pts/0    R+   23:02   0:00  \_ ps auxf
root         1  0.0  0.0   4628   812 ?        Ss   22:52   0:00 /bin/sh -c /entrypoint.sh
root         6  0.0  0.0  18376  3196 ?        S    22:52   0:00 /bin/bash /entrypoint.sh
root         7  0.2  0.9 181704 77824 ?        S    22:52   0:01  \_ perl ./infinitude daemon -m debug
nebulous commented 4 years ago

There's not much more to log on startup, but maybe what you're missing is -f for follow, so you can see logging of actual requests between the 'stat and the browser.

That is, docker logs -f infinitude

bdf0506 commented 4 years ago

-f doesn't really do much in this case. When I look at the infitude source code, I see a bunch of lines like: $c->app->log->debug("-------- Getting systems.xml (".$c->stash('id').") from infinitude.");

I would expect that starting the container with a mode of debug, it would actually print these debug log messages, but this doesn't seem to be the case. I seem to recall that when I was running infinitude not in a docker container, there was either a log file created, or it was written to stdout or something similar.

bdf0506 commented 4 years ago

Ah, figured it out. To get debug logs, you don't want a MODE of "debug", but rather you want a MODE of "development". Doing this will then print debug messages to docker logs.

MODE is set to development
Can't find serial device: /dev/ttyUSB0. Serial monitoring disabled.
[Tue Jun 23 15:49:36 2020] [info] Listening at "http://*:3000"
[Tue Jun 23 15:49:40 2020] [debug] GET "/"
[Tue Jun 23 15:49:40 2020] [debug] Routing to a callback
[Tue Jun 23 15:49:40 2020] [debug] 304 Not Modified (0.000723s, 1383.126/s)
[Tue Jun 23 15:49:40 2020] [debug] GET "/serial"
[Tue Jun 23 15:49:40 2020] [debug] Routing to a callback

Overall, I believe that some changes should be made to the Infinitude code, so that some messages are INFO rather than DEBUG, but will leave that to @nebulous to make that call.

nebulous commented 4 years ago

Ah, nice. Sorry I haven't had a chance to dig into my dev system for this, but I'm glad to see you got it sorted. Any debugging levels currently are completely arbitrary thusfar, so I'll be happy to merge a PR with level changes!