logger

A lightweight, modern and flexible, log4j and futile.logger inspired logging utility for R

https://github.com/daroczig/logger

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (19.0%) to scientific vocabulary

Keywords from Contributors

tidy-data rmarkdown pandoc shiny transition setup visualisation literate-programming devtools latex
Last synced: 10 months ago · JSON representation

Repository

A lightweight, modern and flexible, log4j and futile.logger inspired logging utility for R

Basic Info
Statistics
  • Stars: 307
  • Watchers: 4
  • Forks: 46
  • Open Issues: 22
  • Releases: 0
Created over 7 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# logger logger website


[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active) [![CRAN](https://www.r-pkg.org/badges/version/logger)](https://cran.r-project.org/package=logger) [![Build Status](https://github.com/daroczig/logger/workflows/R-CMD-check/badge.svg)](https://github.com/daroczig/logger/actions) [![Code Coverage](https://codecov.io/gh/daroczig/logger/branch/master/graph/badge.svg)](https://app.codecov.io/gh/daroczig/logger) [![A Mikata Project](https://mikata.dev/img/badge.svg)](https://mikata.dev)


A lightweight, modern and flexible logging utility for R -- heavily inspired by the `futile.logger` R package and `logging` Python module.

## Installation

[![CRAN version](https://www.r-pkg.org/badges/version-ago/logger)](https://cran.r-project.org/package=logger)

```{r}
#| eval: false
install.packages("logger")
```

The most recent, development version of `logger` can also be installed from GitHub:

```{r}
#| eval: false
# install.packages("pak")
pak::pak("daroczig/logger")
```

## Quick example

Setting the log level threshold to something low and logging various messages in ad-hoc and programmatic ways:

```{r}
#| include: false
library(logger)
log_appender(appender_stdout)
```

```{r}
library(logger)
log_threshold(DEBUG)
log_info("Script starting up...")

pkgs <- available.packages()
log_info("There are {nrow(pkgs)} R packages hosted on CRAN!")

for (letter in letters) {
  lpkgs <- sum(grepl(letter, pkgs[, "Package"], ignore.case = TRUE))
  log_level(
    if (lpkgs < 5000) TRACE else DEBUG,
    "{lpkgs} R packages including the {shQuote(letter)} letter"
  )
}

log_warn("There might be many, like {1:2} or more warnings!!!")
```

You can even use a custom log layout to render the log records with colors, as you can see in `layout_glue_colors()`:

colored log output

But you could set up any custom colors and layout, eg using custom colors only for the log levels, make it grayscale, include the calling function or R package namespace with specific colors etc. For more details, see `vignette("write_custom_extensions")`.

## Related work

There are many other logging packages available on CRAN:

- [`futile.logger`](https://cran.r-project.org/package=futile.logger): probably the most popular `log4j` variant (and I'm a big fan)
- [`logging`](https://cran.r-project.org/package=logging): just like Python's `logging` package
- [`lgr`](https://cran.r-project.org/package=lgr): built on top of R6.
- [`loggit`](https://cran.r-project.org/package=loggit): capture `message`, `warning` and `stop` function messages in a JSON file
- [`log4r`](https://cran.r-project.org/package=log4r): `log4j`-based, object-oriented logger
- [`rsyslog`](https://cran.r-project.org/package=rsyslog): logging to `syslog` on 'POSIX'-compatible operating systems
- [`lumberjack`](https://cran.r-project.org/package=lumberjack): provides a special operator to log changes in data

Why use logger? I decided to write the `n+1`th extensible `log4j` logger that fits my liking --- and hopefully yours as well --- with the aim to:

- Keep it close to `log4j`.
- Respect the modern function/variable naming conventions and general R coding style.
- By default, rely on `glue()` when it comes to formatting / rendering log messages, but keep it flexible if others prefer `sprintf()` (e.g. for performance reasons) or other functions.
- Support vectorization (eg passing a vector to be logged on multiple lines).
- Make it easy to extend with new features (e.g. custom layouts, message formats and output).
- Prepare for writing to various services, streams etc
- Provide support for namespaces, preferably automatically finding and creating a custom namespace for all R packages writing log messages, each with optionally configurable log level threshold, message and output formats.
- Allow stacking loggers to implement logger hierarchy -- even within a namespace, so that the very same `log` call can write all the `TRACE` log messages to the console, while only pushing `ERROR`s to DataDog and eg `INFO` messages to CloudWatch.
- Optionally colorize log message based on the log level.
- Make logging fun!

Welcome to the [Bazaar](https://en.wikipedia.org/wiki/The_Cathedral_and_the_Bazaar)! If you already use any of the above packages for logging, you might find `vignette("migration")` useful.

## Interested in more details?

::: .pkgdown-hide

Check out the main documentation site at  or the vignettes on the below topics:

* [Introduction to logger](https://daroczig.github.io/logger/articles/Intro.html)
* [The Anatomy of a Log Request](https://daroczig.github.io/logger/articles/anatomy.html)
* [Customizing the Format and the Destination of a Log Record](https://daroczig.github.io/logger/articles/customize_logger.html)
* [Writing Custom Logger Extensions](https://daroczig.github.io/logger/articles/write_custom_extensions.html)
* [Migration Guide from other logging packages](https://daroczig.github.io/logger/articles/migration.html)
* [Logging from R Packages](https://daroczig.github.io/logger/articles/r_packages.html)
* [Simple Benchmarks on Performance](https://daroczig.github.io/logger/articles/performance.html)

:::

If you prefer visual content, you can watch the video recording of the "Getting things logged" talk at RStudio::conf(2020):

[![Gergely Daroczi presenting "Getting things logged" on using the `logger` R package at the RStudio conference in 2020](https://img.youtube.com/vi/_rUuBbml9dU/0.jpg)](https://www.youtube.com/watch?v=_rUuBbml9dU)

Owner

  • Name: Gergely Daróczi
  • Login: daroczig
  • Kind: user
  • Location: Los Angeles & Hungary
  • Company: @SpareCores / @rxstudioinc

Happy #rstats dev & open-source enthusiast, ex @cardcorp & @openmail, (co)founder of @rxstudioinc, @Rapporter, Hun RUG, @satRdays & @eRum2018 confs. Father of 4

GitHub Events

Total
  • Issues event: 17
  • Watch event: 16
  • Issue comment event: 44
  • Push event: 30
  • Pull request review comment event: 10
  • Pull request review event: 14
  • Pull request event: 19
  • Fork event: 3
  • Create event: 1
Last Year
  • Issues event: 17
  • Watch event: 16
  • Issue comment event: 44
  • Push event: 30
  • Pull request review comment event: 10
  • Pull request review event: 14
  • Pull request event: 19
  • Fork event: 3
  • Create event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 660
  • Total Committers: 30
  • Avg Commits per committer: 22.0
  • Development Distribution Score (DDS): 0.315
Past Year
  • Commits: 185
  • Committers: 9
  • Avg Commits per committer: 20.556
  • Development Distribution Score (DDS): 0.443
Top Committers
Name Email Commits
Gergely Daroczi (@daroczig) d****g@r****t 452
Hadley Wickham h****m@g****m 103
Thomas Lin Pedersen t****5@g****m 19
Maciej Nasinski n****j@g****m 16
Panagiotis Cheilaris p****s@c****r 9
shikokuchuo 5****o 7
Amy Tzu-Yu Chen a****9@g****m 6
Marcin 1****r 6
Wurm Peter p****m@i****t 5
Jean-Francois Zinque j****e@g****m 4
Bill Evans B****l@8****m 4
atusy 3****y 4
deeenes t****s@g****m 4
Michael Chirico m****4@g****m 3
Artem Klevtsov a****v@g****m 2
Samuele s****u@t****t 2
Aaron Jacobs a****s@c****m 1
André Veríssimo 2****o 1
Dan Chaltiel d****l@g****m 1
Dénes Tóth t****s@k****u 1
E. Ariño de la Rubia e****o@g****m 1
Jozef j****a@g****m 1
Masaki Terashi t****i@a****p 1
Maximilian Muecke m****n@g****m 1
Pawel Rucki 1****u 1
aaelony a****y@g****m 1
burgikukac t****d@g****m 1
Taeke Harkema t****a@v****l 1
Samuele Tecchio s****o@s****r 1
kpagacz k****z@c****m 1

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 119
  • Total pull requests: 104
  • Average time to close issues: 8 months
  • Average time to close pull requests: 3 months
  • Total issue authors: 77
  • Total pull request authors: 28
  • Average comments per issue: 2.87
  • Average comments per pull request: 1.88
  • Merged pull requests: 83
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 11
  • Pull requests: 24
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 16 days
  • Issue authors: 8
  • Pull request authors: 5
  • Average comments per issue: 1.09
  • Average comments per pull request: 2.13
  • Merged pull requests: 19
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • r2evans (11)
  • daroczig (11)
  • camult (4)
  • thomasp85 (4)
  • hadley (4)
  • pawelru (3)
  • deeenes (3)
  • Polkas (2)
  • mikekaminsky (2)
  • przell (2)
  • schmalte04 (2)
  • 1beb (2)
  • WurmPeter (2)
  • GitHunter0 (2)
  • razz-matazz (2)
Pull Request Authors
  • hadley (70)
  • daroczig (24)
  • thomasp85 (14)
  • r2evans (6)
  • shikokuchuo (6)
  • deeenes (4)
  • MichaelChirico (4)
  • averissimo (3)
  • m7pr (3)
  • atusy (3)
  • WurmPeter (2)
  • aecoleman (2)
  • pawelru (2)
  • bobjansen (1)
  • DanChaltiel (1)
Top Labels
Issue Labels
bug (17) enhancement (5) help wanted (4) under review (3) more information needed (2)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cran 65,226 last-month
  • Total docker downloads: 91,164
  • Total dependent packages: 40
    (may contain duplicates)
  • Total dependent repositories: 128
    (may contain duplicates)
  • Total versions: 11
  • Total maintainers: 1
cran.r-project.org: logger

A Lightweight, Modern and Flexible Logging Utility

  • Versions: 6
  • Dependent Packages: 37
  • Dependent Repositories: 127
  • Downloads: 65,226 Last month
  • Docker Downloads: 91,164
Rankings
Stargazers count: 1.8%
Dependent repos count: 1.9%
Forks count: 2.2%
Dependent packages count: 2.4%
Downloads: 3.0%
Average: 5.4%
Docker downloads count: 21.1%
Maintainers (1)
Last synced: 11 months ago
proxy.golang.org: github.com/daroczig/logger
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.5%
Average: 5.6%
Dependent repos count: 5.8%
Last synced: 11 months ago
conda-forge.org: r-logger
  • Versions: 4
  • Dependent Packages: 3
  • Dependent Repositories: 1
Rankings
Dependent packages count: 15.6%
Average: 23.7%
Dependent repos count: 24.3%
Stargazers count: 24.8%
Forks count: 29.9%
Last synced: 11 months ago

Dependencies

DESCRIPTION cran
  • futile.logger * enhances
  • log4r * enhances
  • logging * enhances
  • utils * imports
  • R.utils * suggests
  • RPushbullet * suggests
  • botor * suggests
  • callr * suggests
  • covr * suggests
  • crayon * suggests
  • devtools * suggests
  • glue * suggests
  • jsonlite * suggests
  • knitr * suggests
  • pander * suggests
  • parallel * suggests
  • rmarkdown * suggests
  • roxygen2 * suggests
  • rsyslog * suggests
  • shiny * suggests
  • slackr >= 1.4.1 suggests
  • syslognet * suggests
  • telegram * suggests
  • testthat * suggests
  • txtq * suggests
inst/demo-packages/logger-tester-package/DESCRIPTION cran
  • logger * imports
.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v3 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.4.1 composite
  • actions/checkout v3 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/test-coverage.yaml actions
  • actions/checkout v3 composite
  • actions/upload-artifact v3 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite