-
Notifications
You must be signed in to change notification settings - Fork 50
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
A way to tell that logging to a pipe should be as if it's tty #130
Comments
Is that due to the built-in logging? If so, a few options you could try:
|
I need error messages, just without timestamps on non-tty ios. I want to emit good error messages if arguments are invalid, and I test I do have a workaround by using
I could use |
Ah, ok, thanks for the details. The code right now omits timestamps if it's not a TTY like so: optparse-plus/lib/optparse_plus/cli_logger.rb Lines 97 to 98 in 3c0a84a
This is what optparse-plus/lib/optparse_plus/cli_logger.rb Lines 41 to 43 in 3c0a84a
Since that's public, you could use that either always or only when a flag is given. In your main executable, you should be able to do something like: main do
logger.formatter = OptparsePlus::CLILogger::BLANK_FORMAT
# ...
end
# or
main do
if options["omit-message-timestamps"]
logger.formatter = OptparsePlus::CLILogger::BLANK_FORMAT
end
# ...
end
# set this in your tests when you invoke the function
on("--omit-message-timestamps")
```
That all being said, I could see making this more of a builtin feature, but let me know if this works for you |
Thanks for a quick and comprehensive reply. It would work for me, and having a builtin feature would be great. I originally thought an option would just pollute option list, but now I think that somebody might pipe program output and the option would come in handy. |
I'm testing my program with RSpec, by calling it with backticks
./bin/name
, and the output includes timestamps. They get in the way.If there was a way to make it output user-facing output, it'd be awesome. For example,
OPTPARSE_PLUS_TTY=1 ./bin/name
.The text was updated successfully, but these errors were encountered: