wouterdebie / locast2tuner

Locast to Emby/Plex/Channels server
https://wouterdebie.github.io/locast2tuner/
MIT License
52 stars 8 forks source link

Add --logfile #12

Closed wouterdebie closed 3 years ago

wouterdebie commented 3 years ago

Currently locast2tuner only logs to stdout and it would be nice to be able to specify --logfile (as locast2dvr has) to log in a specific location as well.

Croq360 commented 3 years ago

When you add this, if there's an easy way to have different verbosity of logs on what goes to the screen vs what goes to the logs, that'd be helpful. And similarly, I know you can set the environment variably RUST_BACKTRACE (values I know of are 1 and FULL) - if that could be configurable instead of having to set it in the environment, that could help too.

Having more detailed logging in the logfile could definitely help if we need to send you bug reports.

wouterdebie commented 3 years ago

Good points. Let me check if I can set the RUST_BACKTRACE inside the application, because that would make debugging in especially containers much easier.

I'm pretty sure we can make a distinction in loglevel between what goes to the screen and what ends up in the logfile.

wouterdebie commented 3 years ago

Fixed in 66f944d / v0.1.19

wouterdebie commented 3 years ago

Version 0.1.19 adds support for a log file as well as logging to syslog. The previous implementation was a bit of a hack to not include timestamps when there was no tty, but that seemed not super nice. v0.1.20 removes the --force_timestamp option, since I think logging to a file should always include a timestamp and syslog will take care of timestamping itself.

Now the question is if the Docker version and the Ubuntu/RPi version need to start with --syslog or not, in order to properly log. @eiddor any idea?

eiddor commented 3 years ago

Now the question is if the Docker version and the Ubuntu/RPi version need to start with --syslog or not, in order to properly log. @eiddor any idea?

Not sure off-hand, but I will test tonight/tomorrow. You mean starting locast2tuner itself with the --syslog option, correct?

wouterdebie commented 3 years ago

Exactly. For Ubuntu/Debian that probably works. Not so sure about Docker

On Thu, Apr 15, 2021, 15:44 Roddie Hasan @.***> wrote:

Now the question is if the Docker version and the Ubuntu/RPi version need to start with --syslog or not, in order to properly log. @eiddor https://github.com/eiddor any idea?

Not sure off-hand, but I will test tonight/tomorrow. You mean starting locast2tuner itself with the --syslog option, correct?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/wouterdebie/locast2tuner/issues/12#issuecomment-820718347, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABKABVQBWS6UYC5Y74JGALTI5FZRANCNFSM42NPJW6Q .

eiddor commented 3 years ago

Oh, Docker - logging to syslog on the host. That's an interesting one. I'll do some research.

wouterdebie commented 3 years ago

We don't have to. I assume just regular output is fine.

On Thu, Apr 15, 2021 at 3:47 PM Roddie Hasan @.***> wrote:

Oh, Docker - logging to syslog on the host. That's an interesting one. I'll do some research.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/wouterdebie/locast2tuner/issues/12#issuecomment-820720022, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABKABQCQSXOOHU7HM4F7BLTI5GFBANCNFSM42NPJW6Q .

eiddor commented 3 years ago

Ok, let me think about this -

It depends on how much you think logging will be needed. We could always log inside of the container and then add a troubleshooting guide for users to either view it inside the container in real time, or to map it to a volume on the host the same way they do the config file.

On Thu, Apr 15, 2021 at 3:57 PM Wouter de Bie @.***> wrote:

We don't have to. I assume just regular output is fine.

On Thu, Apr 15, 2021 at 3:47 PM Roddie Hasan @.***> wrote:

Oh, Docker - logging to syslog on the host. That's an interesting one. I'll do some research.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub < https://github.com/wouterdebie/locast2tuner/issues/12#issuecomment-820720022 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AABKABQCQSXOOHU7HM4F7BLTI5GFBANCNFSM42NPJW6Q

.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/wouterdebie/locast2tuner/issues/12#issuecomment-820725455, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZ4HK4CBWQ7AMOJ2ETNPY3TI5HKXANCNFSM42NPJW6Q .

wouterdebie commented 3 years ago

@eiddor I think it works well right now with just logging to the terminal. There's a way to use syslog, but I don't think that's necessary for now.

I think adding --syslog to the systemd service definition makes sense. Maybe even --quiet --syslog, because that way we don't have to care about if timestamps should be added or not.

eiddor commented 3 years ago

@eiddor I think it works well right now with just logging to the terminal. There's a way to use syslog, but I don't think that's necessary for now.

I agree - It's easy enough to eliminate -d when starting the container to just have the terminal. That's how I've been doing it so far. In theory (at least in my mind) the more mature the project gets, the less this will be required.

I think adding --syslog to the systemd service definition makes sense. Maybe even --quiet --syslog, because that way we don't have to care about if timestamps should be added or not.

It looks like it's trying to log to /var/run/syslog instead of /var/log/syslog

For the deb package, is logging to syslog something we really want to do by default vs. having a custom log? Do we not worry about cluttering it up with normal messages?

wouterdebie commented 3 years ago

Logging to /var/run/syslog is correct, since it's a named pipe. But maybe you're right about logging to a different file. Let me see how other packages do this. I assume most log through syslog, but add an additional facility.

On Thu, Apr 15, 2021, 18:21 Roddie Hasan @.***> wrote:

@eiddor https://github.com/eiddor I think it works well right now with just logging to the terminal. There's a way to use syslog, but I don't think that's necessary for now.

I agree - It's easy enough to eliminate -d when starting the container to just have the terminal. That's how I've been doing it so far. In theory (at least in my mind) the more mature the project gets, the less this will be required.

I think adding --syslog to the systemd service definition makes sense. Maybe even --quiet --syslog, because that way we don't have to care about if timestamps should be added or not.

It looks like it's trying to log to /var/run/syslog instead of /var/log/syslog

For the deb package, is logging to syslog something we really want to do by default vs. having a custom log? Do we not worry about cluttering it up with normal messages?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/wouterdebie/locast2tuner/issues/12#issuecomment-820796585, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABKABTRBYTGKPK4UMS6M4LTI5YHDANCNFSM42NPJW6Q .

eiddor commented 3 years ago

Logging to /var/run/syslog is correct, since it's a named pipe

Ahh, ok - that makes sense. Raspbian isn't too happy about it, though ;-)

Apr 16 00:18:37 raspberrypi locast2tuner[21242]: config selected = /etc/locast2tuner/config
Apr 16 00:18:37 raspberrypi locast2tuner[21242]: thread 'main' panicked at 'Failed to start syslog on `/var/run/syslog`. Error Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/logging.rs:56:21
Apr 16 00:18:37 raspberrypi locast2tuner[21242]: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Apr 16 00:18:37 raspberrypi systemd[1]: locast2tuner.service: Main process exited, code=killed, status=6/ABRT
Apr 16 00:18:37 raspberrypi systemd[1]: locast2tuner.service: Failed with result 'signal'.

Updating on the Ubuntu VM to test.

eiddor commented 3 years ago

Same message with Ubuntu.

wouterdebie commented 3 years ago

Ah! I'll test later!

On Thu, Apr 15, 2021, 18:31 Roddie Hasan @.***> wrote:

Same message with Ubuntu.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/wouterdebie/locast2tuner/issues/12#issuecomment-820802491, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABKABRAOWT73VEAZ76GTJLTI5ZNBANCNFSM42NPJW6Q .

eiddor commented 3 years ago

Sounds good!

Note: The reason I asked how necessary this was is because without any logging options, we can always look at journald for the output with journalctl -u locast2tuner

wouterdebie commented 3 years ago

@eiddor cool! I'll probably have a look tomorrow.. I just released 0.1.23 (currently building, but available in 15 mins or so) with locast2tuner.service reverted.

wouterdebie commented 3 years ago

@eiddor I just tested this myself on Ubuntu and it seems to work. I went for not using syslog for Ubuntu/Debian, but I've added a log directory in /var/log/locast2tuner where we log now. Let me know what you experience before I close this ticket.

eiddor commented 3 years ago

This works on both Ubuntu and RPi! Thank you!