{"id":16572098,"url":"https://github.com/eddelbuettel/rcppspdlog","last_synced_at":"2025-07-03T08:36:36.314Z","repository":{"id":42461940,"uuid":"288733325","full_name":"eddelbuettel/rcppspdlog","owner":"eddelbuettel","description":"Bundling of spdlog for use from R and Rcpp","archived":false,"fork":false,"pushed_at":"2025-06-28T13:42:05.000Z","size":2446,"stargazers_count":18,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-28T14:36:32.270Z","etag":null,"topics":["logging-library","r","r-package","rcpp","spdlog"],"latest_commit_sha":null,"homepage":"https://eddelbuettel.github.io/rcppspdlog","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eddelbuettel.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-08-19T13:01:58.000Z","updated_at":"2025-06-28T13:42:09.000Z","dependencies_parsed_at":"2025-03-30T19:22:11.771Z","dependency_job_id":"e5257d9a-e676-47f2-9858-fc62336a9077","html_url":"https://github.com/eddelbuettel/rcppspdlog","commit_stats":{"total_commits":129,"total_committers":1,"mean_commits":129.0,"dds":0.0,"last_synced_commit":"5a9e11e3ca98b9f2d60f16cc673b30459051325e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eddelbuettel/rcppspdlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Frcppspdlog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Frcppspdlog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Frcppspdlog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Frcppspdlog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eddelbuettel","download_url":"https://codeload.github.com/eddelbuettel/rcppspdlog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eddelbuettel%2Frcppspdlog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263291404,"owners_count":23443752,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logging-library","r","r-package","rcpp","spdlog"],"created_at":"2024-10-11T21:26:21.597Z","updated_at":"2025-07-03T08:36:36.287Z","avatar_url":"https://github.com/eddelbuettel.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## RcppSpdlog: Bundling of spdlog for use from R and Rcpp\n\n[![CI](https://github.com/eddelbuettel/rcppspdlog/actions/workflows/ci.yaml/badge.svg)](https://github.com/eddelbuettel/rcppspdlog/actions/workflows/ci.yaml)\n[![License](https://img.shields.io/badge/license-GPL%20%28%3E=%202%29-brightgreen.svg?style=flat)](https://www.gnu.org/licenses/gpl-2.0.html)\n[![CRAN](https://www.r-pkg.org/badges/version/RcppSpdlog)](https://cran.r-project.org/package=RcppSpdlog)\n[![r-universe](https://eddelbuettel.r-universe.dev/badges/RcppSpdlog)](https://eddelbuettel.r-universe.dev/RcppSpdlog)\n[![Dependencies](https://tinyverse.netlify.app/badge/RcppSpdlog)](https://cran.r-project.org/package=RcppSpdlog)\n[![Downloads](https://cranlogs.r-pkg.org/badges/RcppSpdlog?color=brightgreen)](https://www.r-pkg.org/pkg/RcppSpdlog)\n[![Last Commit](https://img.shields.io/github/last-commit/eddelbuettel/rcppspdlog)](https://github.com/eddelbuettel/rcppspdlog)\n[![Documentation](https://img.shields.io/badge/documentation-is_here-blue)](https://eddelbuettel.github.io/rcppspdlog/)\n\n\n### About\n\nThe [spdlog](https://github.com/gabime/spdlog) library is a widely-used and very capable header-only\nC++ library for logging.  This package includes its headers as an R package to permit other R\npackages to deploy it via a simple `LinkingTo: RcppSpdlog` as described in [Section 1.1.3 of\nWRE](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Package-Dependencies). As\nof version 0.0.9, it also provides both simple R logging functions and\ncompiled functions callable by other packages as described in [Section 5.4.3\nof WRE](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Linking-to-native-routines-in-other-packages).\n\n\n### Example\n\nA simple first example, following the upstream examples:\n\n```sh\nedd@rob:~$ Rscript -e 'Rcpp::sourceCpp(\"inst/examples/exampleOne.cpp\")'\n\nR\u003e exampleOne()\n[07:45:57.168673] [I] [thread 1500593] Welcome to spdlog!\n[07:45:57.168704] [E] [thread 1500593] Some error message with arg: 1\n[07:45:57.168707] [W] [thread 1500593] Easy padding in numbers like 00000012\n[07:45:57.168710] [C] [thread 1500593] Support for int: 42;  hex: 2a;  oct: 52; bin: 101010\n[07:45:57.168728] [I] [thread 1500593] Support for floats 1.23\n[07:45:57.168731] [I] [thread 1500593] Positional args are supported too..\n[07:45:57.168734] [I] [thread 1500593] left aligned\n[07:45:57.168737] [D] [thread 1500593] This message should be displayed..\nedd@rob:~$\n```\n\nThis logs the hour, minute, second, microsecond followed by a one-char code for info, error, warning\nor critical followed by the thread id and the actual loggable message. The code, apart from the\nincluded headers and more, is simply\n\n```c++\n// [[Rcpp::export]]\nvoid exampleOne() {\n\n  // change log pattern (changed from [%H:%M:%S %z] [%n] [%^---%L---%$] )\n  spdlog::set_pattern(\"[%H:%M:%S.%f] [%L] [thread %t] %v\");\n\n  spdlog::info(\"Welcome to spdlog!\");\n  spdlog::error(\"Some error message with arg: {}\", 1);\n\n  spdlog::warn(\"Easy padding in numbers like {:08d}\", 12);\n  spdlog::critical(\"Support for int: {0:d};  hex: {0:x};  oct: {0:o}; bin: {0:b}\", 42);\n  spdlog::info(\"Support for floats {:03.2f}\", 1.23456);\n  spdlog::info(\"Positional args are {1} {0}..\", \"too\", \"supported\");\n  spdlog::info(\"{:\u003c30}\", \"left aligned\");\n\n  spdlog::set_level(spdlog::level::debug); // Set global log level to debug\n  spdlog::debug(\"This message should be displayed..\");\n\n  // Compile time log levels\n  // define SPDLOG_ACTIVE_LEVEL to desired level\n  SPDLOG_TRACE(\"Some trace message with param {}\", {});\n  SPDLOG_DEBUG(\"Some debug message\");\n\n}\n```\n\nMany other customizations are possible, see the [spdlog\nwiki](https://github.com/gabime/spdlog/wiki).\n\nNote that using `spdlog` examples directly _may_ well trigger warning from R during package checking\nas `stdout` and/or `stderr` may be used. See the included example function described in the next\nsection which uses a derived class to pass logging output explicitly to the R input/output stream as\nper the R coding requirements, see [Section 1.3.1 (and others) of\nWRE](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Checking-packages).\n\n\n### Use in R Packages and Warnings\n\nAs shipped, both [spdlog](https://github.com/gabime/spdlog) and the embedded\n[fmt](https://github.com/fmtlib/fmt) use `stdout` and `stderr` in ways that may make it non-trivial\nto fully replace them with R input/output as required by [Section 1.3.1 (and others) of\nWRE](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Checking-packages).\n\nHowever, based on some initial trials and some excellent help from upstream we have defined a\nspecific sink for R in the header\n[`rcpp_sink.h`](https://github.com/eddelbuettel/rcppspdlog/blob/master/inst/include/rcpp_sink.h),\ncorrected one `stderr` use and added one `#define`.  That combination now passes as can be seen in\nchecks of the package `RcppSpdlog` and the included function `exampleRsink()` whose complete source\ncode is included here:\n\n```c++\n\n// this portmanteau include also defines the r_sink we use below, and which\n// diverts all logging to R via the Rcpp::Rcout replacement for std::cout\n#include \u003cRcppSpdlog\u003e\n\n//' spdlog Example using a sink for R\n//'\n//' A simple example invoking a derived R/Rcpp logger. Also demonstrates the\n//' stopwatch feature. For more features see the 'spdlog' documnetation.\n//'\n//' Note that this no longer triggers R warnings thanks to excellent help by\n//' Gabi Melman.\n//' @return None\n//' @examples\n//' exampleRsink()\n// [[Rcpp::export]]\nvoid exampleRsink() {\n\n    std::string logname = \"fromR\";                          // fix a name for this logger\n    auto sp = spdlog::get(logname);                         // retrieve existing one\n    if (sp == nullptr) sp = spdlog::r_sink_mt(logname);     // or create new one if needed\n\n    spdlog::stopwatch sw;                                   // instantiate a stop watch\n\n    // change log pattern (changed from [%H:%M:%S %z] [%n] [%^---%L---%$] )\n    spdlog::set_pattern(\"[%H:%M:%S.%f] [%n] [%^%L%$] [thread %t] %v\");\n\n    spdlog::info(\"Welcome to spdlog!\");\n    spdlog::error(\"Some error message with arg: {}\", 1);\n    spdlog::info(\"Elapsed time: {}\", sw);\n\n    spdlog::warn(\"Easy padding in numbers like {:08d}\", 12);\n    spdlog::critical(\"Support for int: {0:d};  hex: {0:x};  oct: {0:o}; bin: {0:b}\", 42);\n    spdlog::info(\"Support for floats {:03.2f}\", 1.23456);\n    spdlog::info(\"Positional args are {1} {0}..\", \"too\", \"supported\");\n    spdlog::info(\"{:\u003c30}\", \"left aligned\");\n    spdlog::info(\"Elapsed time: {}\", sw);\n\n}\n```\n\nNote that it is deliberately similar in use to the example above.  A new instance of the logger is\ninstantiated as a shared pointer `sp` to a `spdlog` object. Similarly, a stopwatch is instantiated\nused simply by referring to it.\n\nWe may make additional package features available in the future.\n\n### See Also\n\nThe [spdl](https://github.com/eddelbuettel/spdl) package, now also on CRAN, wraps around this\npackage to provide a _uniform and consistent_ logging interface from both R _and_ C++.  It defines a\nnew C++ namespace `spdl` along with matching R functions.\n\n\n### Author\n\n[Gabi Melman](https://github.com/gabime) is the main author of [spdlog](https://github.com/gabime/spdlog).\n\n[Victor Zverovich](https://github.com/vitaut) is the main author of the embedded [fmt](https://github.com/fmtlib/fmt) library.\n\n[Dirk Eddelbuettel](https://dirk.eddelbuettel.com) is author of this package and the R integration.\n\n### License\n\n[spdlog](https://github.com/gabime/spdlog) and [fmt](https://github.com/fmtlib/fmt) are under the\nMIT license.\n\nRcppSpdlog is released under the GNU GPL, version 2 or later, just like R and Rcpp.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Frcppspdlog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feddelbuettel%2Frcppspdlog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feddelbuettel%2Frcppspdlog/lists"}