Skip to content
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

Plumber messages are sent to stderr instead of stdout #492

Closed
david-cortes opened this issue Sep 30, 2019 · 3 comments
Closed

Plumber messages are sent to stderr instead of stdout #492

david-cortes opened this issue Sep 30, 2019 · 3 comments
Labels
will not fix No intended plans to ever address issue
Milestone

Comments

@david-cortes
Copy link

Steps to reproduce:

  • Configure stdout and stderr to output to different places.
  • Launch plumber through Rscript with a file like this:
library(plumber)
r <- plumb("some_file.R")
r$run(host = host, port = port)
  • Check the standard output and standard error that is produced.

Expected behavior: information messages such as

Starting server to listen on port 1234

should go into standard output.

Actual behavior: information messages go into standard error instead.

@schloerke schloerke added difficulty: novice Anyone could help help wanted Solution is well-specified enough that any community member could fix priority: low Will be fixed eventually type: bug Maintainers have validated that it is a real bug in the project code labels Sep 30, 2019
@schloerke schloerke added this to the v0.5.0 - Next CRAN release milestone Sep 30, 2019
@schloerke
Copy link
Collaborator

schloerke commented Sep 30, 2019

Good catch!

I believe message produces stderr output. We should probably change them to cat statements where appropriate.

@aronatkins
Copy link
Contributor

Prior art: shiny emits a "Listening on ..." message.
https://github.com/rstudio/shiny/blob/29d24d7e08f161d79c8f227723fbec67353b6fc9/R/server.R#L590

@atheriel
Copy link
Contributor

It's also possible to catch message() signals at the application level and write them to standard output, if that's what you absolutely need:

withCallingHandlers(
  message("Informational message."),
  message = function(m) {
    cat(m$message)
    invokeRestart("muffleMessage")
  }
)

This can also be used to e.g. catch library messages and reformat them for structured logging output, something that becomes impossible when using cat() directly as proposed.

@schloerke schloerke added will not fix No intended plans to ever address issue and removed difficulty: novice Anyone could help help wanted Solution is well-specified enough that any community member could fix priority: low Will be fixed eventually type: bug Maintainers have validated that it is a real bug in the project code labels Aug 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
will not fix No intended plans to ever address issue
Projects
None yet
Development

No branches or pull requests

4 participants