Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: FLAC and logging (Read 3072 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

FLAC and logging

Hi there

It seems to me that FLAC lacks a formal logging switch
Is directing the screen output to a file (via ">") a safe alternative or a stupid thing to do?
Any drawbacks that I should be aware of?
I'm mostly on Linux, but also use Windows...

Cheers

FLAC and logging

Reply #1
depends on what you want, but most things are possible just using redirects.  informational messages go to stderr (use "2>" in sh/bash/etc) and there are switches tweak what/how much information is printed.

FLAC and logging

Reply #2
Thanks!
I bought a bash book but never made it halfway, plus my memory doesn't help much either

I just tried using "2>" with some defective files i use for testing, and it worked fine.
I was mostly afraid of the process pausing somewhere due to errors, or waiting for keyboard input, and then not having the output on screen.

But is there any way to have the log file AND the normal output still printed to screen?

The reason I ask is cause we are about to FLAC around 5,000 CDs and there will be a whole lot of processing going on
So having both file logging and screen output would be ideal, logging because we cant be there all the time, and the screen output to "see how things are going"...

And these switches, are they documented?
Can't see anything via the normal flac -H or man flac...

FLAC and logging

Reply #3
If you want to redirect both stdout & stderr to a file, here's an example from my (complex) "check hashes" bat I recently created:

Code: [Select]
fsum.exe -c -jf -w "%filename%.md5" >"%rootdir%\temp.txt" 2>&1

The reason I had to do this is because the -w switch checks "improperly formated checksum lines" in the hash file and outputs it to stderr (and on the screen normally), rest of the stuff (checksums failed & file errors) go to normal stdout. Using the "2>&1" has one small annoyance (at least in my case): it doesn't show the output rows in same order than when normally executing the command without redirecting. I.e. the stderr output changes place a bit.

Ok, this doesn't solve your "log and normal output" question. I researched this topic some time ago and in order to achieve what you want, you need to use a tool, a free one, TEE (part of Coreutils - GNU core utilities).

I was going to use (or still a bit undecided) this in my REACT mod. Here's one of my notes about testing TEE:

"It works almost perfectly; when doing BATFILE 2>&1 | tee.exe test.txt, some messages come to the console a bit late, e.g. when the bat-file runs flac.exe, the growing encoding percent indicator does NOT show up in the console until the encoding process is over. The text file though contains all the messages, so it's a small annoyance."

(yes, I do write almost all of my notes in English, not in Finnish )

HTH

FLAC and logging

Reply #4
flac writes all messages to stderr, stdout is only used for piped output (see -c).

to write to screen and a log file at the same time, use tee.

flac doesn't ever pause or wait for keyboard input.

the options that control what is printed are -s -w --totally-silent.