-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging To Preserve Color Output #112
Comments
It took me a second to figure out what you meant by ANSI colors because I didn't write any code for colorizing logs and don't see it for myself. I'm a little groggy and wondered if I woke up in bizarro-world. But Moonfire calls into ffmpeg for its RTSP handling, and ffmpeg logs. There's a hook for overriding the log callback ( As an aside, this makes me realize I probably should be setting the log callback so ffmpeg's logs and Moonfire's are handled consistently. One bad thing with the procedure you're describing here is that it doesn't happen automatically on startup, so after a power failure you have a larger-than-necessary gap in your recording. I think almost anything that supervises processes will do so without creating a tty, so no color. But it should be possible to colorize after the fact. Hmm, this serverfault question points out some canned utilities for those. We could teach it about the log format Moonfire NVR uses (which is based on Google's logging format if they don't already know about it, or change Moonfire NVR's format to match one they already know about. |
lnav also apparently allows nice things like querying the logs with SQLite3. I also realized I'm not quite matching glog's timestamp format. glog has a : separator for the time that I left out by mistake, and (as of recently glog also includes the date. I've also been meaning to add in a guide on how to read the logfiles. That'd be a good place to mention lnav. |
* add more description to the troubleshooting guide * adjust the log format to match more recent glog * include a config for the lnav tool, which will help colorize, browse, and search the logs. Next up: install an ffmpeg log callback for consistency.
I think your comment that you do not colorize your output and that the
ffmpeg errors are passed through is important. I think what must be coming
through to me are ffmpeg errors... lots of rtsp-type errors.
I'm thinking Perl may provide what I feel is needed for managing logs to
address what errors are causing my instance to have two camera failures.
It may be that the problems are emanating from ffmpeg, in which case
preserving their color scheme, rather than trying to after-the-fact
colorize, could be helpful should I have to engage assistance from the
developers of ffmpeg. It would be a good thing to present to them their
logs as they have colorized them.
Later today, I'll post a sample in converted HTML format to give you a
flavor of what I am capturing. It is important to isolate the ffmpeg from
your code's output so triaging where the problem is arising can be quickly
made.
Also, a bit off topic, I have my Xen server running now, so I can devote a
VM to exploring and testing different versions. It is time that I need -
you've seen me rue about this before.
…On Mon, Mar 8, 2021, 10:41 PM Scott Lamb ***@***.***> wrote:
A sufficiently recent lnav <https://lnav.org/> (I tried the one from git;
the one packaged in Debian 10 is too old) will colorize logs after the fact
with the attached format file. How does this look?
$ lnav -i moonfire_log.json
$ lnav nvr-logs
[image: image]
<https://user-images.githubusercontent.com/8949524/110427774-17877800-805d-11eb-8430-bd283e0fcda9.png>
moonfire_log.json.txt
<https://github.com/scottlamb/moonfire-nvr/files/6106309/moonfire_log.json.txt>
lnav also apparently allows nice things like querying the logs with
SQLite3.
I also realized I'm not quite matching glog's timestamp format. glog has a
: separator for the time that I left out by mistake, and (as of recently
<google/glog#516> glog also includes the date.
I've also been meaning to add in a guide on how to read the logfiles.
That'd be a good place to mention lnav.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#112 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABXP4KUNGOMOQAUCBFBWMDTCW7H5ANCNFSM4Y2CK5IA>
.
|
I agree what you're seeing are ffmpeg errors. But to be honest, I'm not optimistic about ffmpeg developers jumping to fix RTSP bug reports with Moonfire NVR logs attached, and I don't think ANSI color output will help that. They haven't even looked at the ones I submitted when I followed their bug reporting instructions that involve reproducing with the That's not to say RTSP problems are hopeless. I definitely want Moonfire NVR to record reliably and welcome bug reports in Moonfire NVR's tracker even if the offending line of code is in ffmpeg. There are several avenues we can take to get them fixed:
|
I've uploaded a 14 MB log file converted to HTML preserving the coloration. It represents March 4th - 9th for a 4 camera operation. I'm sharing this just so you have a quick overview. I would like to first study the log myself and then open another issue for the problem I discern from the log. I'd like to keep this issue relating to the topic of preserving and formatting logs and not have it dive into the underlying problem I am facing. https://drive.google.com/file/d/1UrQgLzgetLfCT8681uOOO9u1a_gGGKjU/view?usp=sharing Here is a sample of how the preserved colorized log appears in Firefox: |
In response to your Comment , For posterity, I took my log file created by "script" and pushed it through ansi2html:
|
Thank you for bringing this up and sharing the example. I just played with that log, and I'm afraid I don't like this format much. Web browers are pretty slow to scroll on a page that large and their built-in find doesn't support jumping to a time, searching by regexp, etc. I find it more pleasant to work with logs via either general-purpose CLI tools ( I did a quick look for how to convert back to plain text. Right now the ANSI colors give you some information about log levels that isn't present in the text (thus the |
I also wouldn't mind too much logs with ANSI color codes in them (without converting to HTML). They're a bit easier than the HTML to strip out: If you want to make logs with those now, the environment variable |
It's kinda looking like there should be a raw ANSI output, then if it desired to share via a Web page, an HTML version can be made, or if a review of the log in a console or Linux environment can strip the escape codes. Having a process defined to achieve these goals is what I am hoping for. You reference to |
ffmpeg was already doing this; now do it for native logs.
Link to newly extended guide on log files (#112)
The logs should be quite a bit friendlier now. The docs on logs have been extended quite a bit and mention a new |
Looks like a refactoring in 9d7cdc0 introduced the possibility this could fail (where before it might produce a silly i32 pts) and forgot to restore the invariant.
Since upgrading, I have found at least one camera, if not two, have erratic saving, if at all. I'm using 4 Reolink cameras This behavior compares with performance I had with Moonfire-nvr software in the version as of June, 2020. While the problem may be with the cameras, or my network, or my Raspberry Pi4, I feel the first thing to do is have a protocol for creating, preserving and staging log files. Al the while, I simultaneously am using Reolink's Windows software to display real time and capture events for all four cameras and its performance does not seem much different. Sometimes I have to reset a camera. But the disparity between a recent version of Moonfire-nvr and June 2020 vs. Reolink's is noteworthy and merits an investigation which I'll undertake. In the meantime, I thought I would post and preserve a protocol I propose to use so that files with the ANSI colors are preserved.
The log files are in color format and I think it is important to retain the ANSI codes coloring the output given that the files can be so large and classes of errors more identifiable when colorized. So, what I have started is a procedure to run moonfire-nvr as following:
In console No. 1:
In console No. 2:
TODO: 1) log rotation without destruction of events, 2) document ansi2html to other display method to share logs while preserving the colorization.
The text was updated successfully, but these errors were encountered: