-
Notifications
You must be signed in to change notification settings - Fork 214
Would be good to have -l option for rex to specify the logfile as with
logging to_file => 'rex.log';
Needed that and searched through https://metacpan.org/dist/Rex/view/bin/rex but couldn't find any.
All reactions
Replies: 1 comment
Hmm, I'm not sure if it's intended as more of a question about how to log to files adhoc, or as a proposal for a new feature :) It looks like a bit of both, so I'm writing replies for both.
First thoughts
Rex currently prints its log messages to STDERR, and any other output (from e.g. print, say, etc.) to STDOUT. Therefore I would first look at using the given shell's standard redirection features to write the output from STDERR and STDOUT to (the same or different) files, and/or tee to print both to screen and file(s).
For example (with bash process substitution): rex run_this_task 2> >(tee /write/logs/here)
Status quo for more context
Some redirection options that are already possible:
- to a file declaratively with
logging to_file => ...as above - to file(s) with standard shell redirection constructs
- to both screen and file at the same time with
tee - to syslog with
logging to_syslogs => ...(and then configuring the syslog service to write it to the desired file)
Slightly related, rex -o is also available to set a custom output handler with a module in the Rex::Output namespace (that's more about different output formatting, though, like for emitting JUnit-compatible XML).
Proposal details
If I understand correctly, the main use of a new -l CLI switch would be to:
- specify a log file to use in a way that is equivalent to
logging to_file => $fileif that is missing from the code - if
logging to_file => $fileis present in the code, override the value to give precedence to the CLI option
Is that correct? What else would a proposed new -l option would do?