Forum How do I...?

Disable fin|success message

vladcostea
Hi, I'm using the prince exe (mac osx) via a Ruby library (princely) and I would like to completely limit the output I get from prince to just the pdf binary (ie: no "fin|success" message)

It seems that --silent does not stop it, neither using a log file with --log.

Is this even possible without redirecting the output?
mikeday
I think you will need to redirect the output, but what is the motivation for this? The final message is used to inform the wrapper whether conversion has succeeded, and shouldn't be causing any problems.
vladcostea
We're using prince in a PDF rendering service, and we need full control of our stdout logging. As you said, redirecting the output seems to be the only way (it's not causing problems, it's just an annoyance). Thank you.
mikeday
I was under the impression that princely is supposed to be capturing stdout from Prince anyway.
vladcostea
I'm kinda forced to use v1.4.1 of princely, not sure about the latest version (2.0.2). Looking at the code, it does seem to do some redirection in v1.4.1.

path << " --silent - -o '#{output_file}' >> '#{log_file}' 2>> '#{log_file}'"


This adds the cmd line options to prince. I've debugged the library, this code is run, yet the "fin|success" message still appears on stdout.

mikeday
Strange! The final log message should be printed to stderr, which should be getting redirected by the command-line you gave above. (The command-line could just say 2>&1 to redirect stderr to wherever stdout is going, I think). Perhaps double-check that this is the actual command-line in use, and are you running on Linux or Windows?

Ruby also has an Open3 module that has a popen3 call giving access to the individual stdin/out/err streams, but that would require a bit more of a rewrite of Princely. (On the plus side it would allow the Ruby code to capture the actual log messages instead of just writing them to a file!)
vladcostea
I double checked, same result (on mac os, same on ubuntu). Thanks for the Open3 suggestion. Most likely, if we decide it's too much of an annoyance, we'll monkey patch the library, otherwise we'll live with it. Thanks again.
vladcostea
I may have been doing something wrong in the first place.

path << " --silent - -o '#{output_file}' >> '#{log_file}' 2>> '#{log_file}'"


does indeed redirect and the message "fin|success" is not shown anymore.

Thanks again
mikeday
Great, glad it's working. :)