knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) options(crayon.enabled = TRUE, width = 1024) fansi::set_knit_hooks(knitr::knit_hooks)
joblog proposes a format for logging the start and completion of jobs via lgr (such as cron jobs or automatically triggered etl operations) and provides utility functions to analyse such logs. It is desinged to showcase the flexibility of lgr, and not useful on its own.
remotes::install_github("s-fleck/joblog")
library(joblog) # setup logging lf <- paste0(tempfile(), ".jsonl") lg <- lgr::get_logger("jobs")$set_propagate(FALSE) # prevent logging to the console lg$add_appender(lgr::AppenderJson$new(file = lf), name = "json") lg$list_log(job_start("example")) # log the job start # ... do stuff ... lg$list_log(job_finished()) # log the job end # run the same job again lg$list_log(job_start("example")) lg$list_log(job_failed("something went wrong")) # log other stuff unrelated to the job lg$info("today is tuesday") lg$warn("only true every 7 days")
Using the setup above we have logged to a json lines file that looks like this:
lg$appenders$json$show()
joblog provides scrape_joblog()
for extracting the jobs from logfile and
consolidating all info about the job from the relevant log entries, based
on the auto-generated job-id.
scrape_joblog(lf)
#cleanup unlink(lf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.