Page 1 of 1
Option to output logfile in plain text (even in 256 color xterm terminal)
Posted: 27 Jan 2017, 16:16
by HansCz
Would it be possible to include an option to force plain text output of the logfile specified with the
option?
It would be desirable, as it would result in more readable logs in less capable terminals and obviate any need for later removal ansicodes if so desired.
Re: Option to output logfile in plain text (even in 256 color xterm terminal)
Posted: 27 Jan 2017, 16:19
by rednoah
256-color output if only enabled if you're using an interactive console, so you won't get color output if you redirect to file or pipe to another process.
Do logs created with
--log-file contain color codes? They shouldn't unless you explicitly force that behaviour.
EDIT:
--log-file does indeed print color codes if the command is called with interactive console. A simple workaround would be to just pipe to cat:
If filebot is called by cron or another process automatically then you won't ever get color codes.
Re: Option to output logfile in plain text (even in 256 color xterm terminal)
Posted: 27 Jan 2017, 16:35
by HansCz
Thanks for the comprehensive answer
For some odd reason I assumed that piping and redirecting would also include the ANSI codes. Good design that they don't [thumbs up]
Here's what I end up doing, should anybody want to know:
Code: Select all
$ filebot -script 'fn:amc' [...a lot of options here...] --log all >>/path/to/log/file.log 2>&1
Note that this will also log anything going to stderr to the log file. In this case it seems to make sense, since I will never run this invocation of filebot in an interactive console.
Re: Option to output logfile in plain text (even in 256 color xterm terminal)
Posted: 27 Jan 2017, 16:45
by rednoah
If filebot is called by a non-interactive shell, it shouldn't be printing color codes in the first place.
However, using 2>&1 has additional benefits and can log errors that the application itself won't be able to log via --log-file due to filebot.sh failing before calling java, the java process itself crashing, logging produced by native code or child processes and so on.
Re: Option to output logfile in plain text (even in 256 color xterm terminal)
Posted: 27 Jan 2017, 17:11
by HansCz
Yes. I was just stupid and assumed during testing in an interactive console, that the ANSI codes would be in the log if filebot were to be called non-interactively. d'oh!
Re: Option to output logfile in plain text (even in 256 color xterm terminal)
Posted: 27 Jan 2017, 17:14
by HansCz
Thank you for an excellent tool, by the way.
I ran my first 20 executions or so manually, watching the log, not trusting it to do the right thing.
I was proven wrong. Filebot really just works! (so far

)
Re: Option to output logfile in plain text (even in 256 color xterm terminal)
Posted: 27 Jan 2017, 17:26
by rednoah
I wouldn't bet my life on it though.
If you have a large number of files, then it's best to deal with them semi-automatically with
--mode interactive or at least do a dry-run with
--action test first.