R shiny: printing the console output produced by an R package to UI

I am using an R package that, in addition to returning things, prints some very useful info to the console. For example, it prints what iteration it is on right now.
How could I print that console output directly to my UI?

Assume this is my UI:

ui <- shinyUI(
    titlePanel("Print consol output"),
      sidebarPanel(actionButton("go", "Go")),

My user clicks on actionButton "Go" and my package starts doing things - while sending stuff to the console at the same time. I guess, I want the content of the console to be saved as output$console_text - but I don't know if that's the right approach and how to do it. Let's say - instead of the package, I just create my own mini-function (inside server).

server <- function(input, output, session) {
 myfunction <- function(x) { 
    for(i in 1:x) cat(i)
  observeEvent(input$go, {
       # This is certainly wrong:
      output$console_text <- renderPrint(result <- myfunction(20))

 shinyApp(ui, server)

Thank you very much!

1 Like

You might find this useful https://gist.github.com/jcheng5/3830244757f8ca25d4b00ce389ea41b3

1 Like

Related resolved SO post by @daattali :