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

It's not clear from the docs how to get logs from Shiny app deployed to Connect #296

Open
thisisnic opened this issue Sep 2, 2024 · 2 comments

Comments

@thisisnic
Copy link

thisisnic commented Sep 2, 2024

I spent a few hours today trying to work out if I deploy my app which has logging built in to Posit Connect, how can I get access to the logs from that app. After a while I figured out a slightly messy way of doing this, via reading #193 and having to work around the issue there.

Here's my very messy first draft code in case anyone else ends up here searching for this

library(connectapi)

# create connection to Connect instance
client <- connect(
  server = <value goes here>,
  api_key = <value goes here>
)

library(dplyr)

# Get guid for specific app
app_guid <- get_content(client) %>%
  filter(title == <app title goes here>) %>% pull(guid)

item <- connectapi::content_item(client, app_guid)
jobs <- connectapi::get_jobs(item)

library(lubridate)

last_days_jobs <- jobs %>% 
  filter(
    tag == "run_app",
    start_time >= now() - days(1)
  )

logs <- lapply(last_days_jobs$key, function(k) {
  try_get_logs <- tryCatch(connectapi::get_job(item, k), error=function(e){})
  try_get_logs$stderr
}) %>%
  unlist()

This is a really useful piece of functionality for deploying Shiny apps in a production environment using Posit Connect, and it feels like something it'd benefit folks to be easier to find!

@toph-allen
Copy link
Collaborator

toph-allen commented Sep 5, 2024

Hey @thisisnic! Thanks for the code! It's a helpful example, both for folks who want to accomplish that, and for us thinking about how to improve connectapi.

I was looking more deeply at the issue you linked, and realized that it should have been closed, because it was apparently fixed earlier in the year. Were you still encountering bugs to do with column conversions?

@thisisnic
Copy link
Author

thisisnic commented Sep 6, 2024

Hey @toph-allen, glad it's useful! Yeah, I am encountering those bugs, but I'm using package version 0.1.3, which is probably/hopefully why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants