posit-dev / posit-dev/connectapi
It's not clear from the docs how to get logs from Shiny app deployed to Connect
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 54
- Forks
- 27
- Avg merge
- 1d 3m
- Merged PRs (30d)
- 1
Description
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!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing documentation for connectapi and the related discussion in issue #193. Trace the example entry points content_item(), get_jobs(), and get_job() to confirm the supported way to retrieve Shiny app logs from Posit Connect. Done means users can find clear documentation for accessing those logs without relying on the workaround shown here.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100