Is there an API available for writing info to the DVR log? I'm running a custom script to track Pluto channel changes and would like to have it output to the log file. Thanks.
I don’t believe there is.
What's stopping you from appending to ${CHANNELS_WORK_DIR}/data/channels-dvr.log directly from your script?
Hmmm...hadn't really thought of writing directly to the log in another running process (Isn't that usually a no-no?)
My point of reference was something like 'logger' under linux to write into the syslog when needed.
Generally, you're right. But in the case of Channels, they don't use any system-level type of logging to write the log file. When I packaged it for Arch, or a separate install, I would have systemd use the file as the stdout/stderr in append, which might affect other processes ability to write the file. I'm not sure what type of file handle that Channels opens when it starts.
If this capability is important to you, you could always use a couple of FIFOs or sockets, and replace the expected Channels log with a shared socket so multiple processes could write to it without issue.
I was looking at pushing the new channels updates to the dvr log, but didn't understand the implications. I ended up pushing the notifications to a database and check for new channels by running a script "new_channels". If you're successful, adding to the existing logs, please report back.
Had to give it a try....it let me do an 'echo' redirect/append to the log file. (the first line tagged [INF] is from my bash script)
2021/05/07 22:00:16.208348 [INF] PlutoTV No channel changes detected
2021/05/07 22:00:16.926463 [M3U] Refreshed lineup for PlutoTV with 303 channels
2021/05/07 22:00:17.133930 [DVR] Fetched guide data for XMLTV-PlutoTV in 0s
2021/05/07 22:00:20.990070 [DVR] Indexed 2476 airings into XMLTV-PlutoTV (148 channels over 27h0m0s) + 3 skipped [3s index]
2021/05/07 22:00:21.000071 [DVR] pruned 292 replaced airings in 0s.
2021/05/07 22:00:21.009073 [IDX] Pruned 333 expired groups from XMLTV-PlutoTV in 9.0024ms.
Why not keep a separate log with an identical timestamp format? Then you could concatenate and sort the files when you want to read the logs as a single stream.
Just for ease of use. If I'm in the DVR web interface and see Pluto added or deleted channels, I can just flip over to the log and see what they were (my script will also print the new or deleted channel name and number to the log)