Skip to content

Navigation Menu

Sign in
Sign up

rex(1): Add "-l" option for CLI logging #1555

rwp0 started this conversation in Ideas
Discussion options

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.

You must be logged in to vote

Replies: 1 comment

Comment options

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 => $file if that is missing from the code
  • if logging to_file => $file is 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?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /