{"id":16623684,"url":"https://github.com/jandelgado/log4arduino","last_synced_at":"2025-10-18T04:03:19.469Z","repository":{"id":27881703,"uuid":"115452842","full_name":"jandelgado/log4arduino","owner":"jandelgado","description":"lightweight, no-frills logging library for Arduino and friends.","archived":false,"fork":false,"pushed_at":"2022-02-13T09:07:12.000Z","size":18,"stargazers_count":6,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-02-26T23:22:48.619Z","etag":null,"topics":["arduino","log4arduino","logging"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jandelgado.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-26T20:30:11.000Z","updated_at":"2022-02-13T08:52:45.000Z","dependencies_parsed_at":"2022-07-27T11:17:31.032Z","dependency_job_id":null,"html_url":"https://github.com/jandelgado/log4arduino","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jandelgado%2Flog4arduino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jandelgado%2Flog4arduino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jandelgado%2Flog4arduino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jandelgado%2Flog4arduino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jandelgado","download_url":"https://codeload.github.com/jandelgado/log4arduino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219857107,"owners_count":16556074,"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":["arduino","log4arduino","logging"],"created_at":"2024-10-12T03:24:37.277Z","updated_at":"2025-10-18T04:03:14.434Z","avatar_url":"https://github.com/jandelgado.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# log4arduino\n\n![build](https://github.com/jandelgado/log4arduino/workflows/build/badge.svg)\n\nA lightweight, no-frills logging library for Arduino \u0026 friends.\n\n* simple interface - just four macros\n* printf-like formatting\n* each log entry is prepended by timestamp and amount of available free RAM\n* automatically uses flash memory to save SRAM (if supported)\n* log target can be any subclass of class `Printer`, e.g. class `Serial`\n* zero memory footprint when turned off\n\n## Example\n\n```c++\n#define ENABLE_LOG4ARDUINO      // opt-in\n#include \u003clog4arduino.h\u003e\n\nvoid setup() {\n    Serial.begin(9600);\n    LOG_INIT(\u0026Serial);\n\n    // use LOG() for printf-like logging\n    LOG(\"hello, log4arduino.\");\n    LOG(\"use %s formatting: %d %c %d %c %d\", \"printf\", 9, '+', 1, '=', 10);\n    constexpr uint32_t magic = 3735928559;\n    LOG(\"hex output: %lu == 0x%lX\", magic, magic);\n\n    // use LOGS() for simple logging of single arguments\n    const char *pStr = \"some string from RAM\";\n    LOGS(pStr);\n    LOGS(String(\"some String object\"));\n    LOGS(123);\n    \n    // these examples are equivalent\n    LOGS(F(\"this string is stored in flash memory\"));\n    FLOGS(\"this string is also stored in flash memory\");\n}\n\nvoid loop() { }\n```\n\nwill print out the following on the `Serial` interface:\n\n```\n0(1623): hello, log4arduino.\n0(1609): use printf formatting: 9 + 1 = 10\n9(1599): hex output: 3735928559 == 0xDEADBEEF\n58(1695): some string from RAM\n91(1695): this string is stored in flash memory\n142(1695): some String object\n174(1695): 123\n```\n\nThe actual log messages are preceeded by the current time as returned by\n`millis()` as well as the free heap space, e.g. `91(1695):`.\n\n## Installation\n\n### Arduino IDE\n\nIn the main menu of the Arduino IDE, select `Sketch` \u003e `Include Library` \u003e\n`Manage Libraries...` and search for `log4arduino`, then press `install`.\n\n### PlatformIO\n\nAdd `log4arduino` to your library dependencies in your `platformio.ini` project\nfile, e.g.\n\n```ini\n...\n[env:nanoatmega328]\nplatform = atmelavr\nboard = nanoatmega328\nframework = arduino\nlib_deps=log4arduino\nbuild_flags=-DENABLE_LOG4ARDUINO\n...\n```\n\nWith the `build_flags` option, you can enable/disable log4arduino at build time.\n\n## API\n\n### Header\n\nTo use log4arduino, define `ENABLE_LOG4ARDUINO` and include the `log4arduino.h`\nheader.  If `ENABLE_LOG4ARDUINO` is not defined, then logging will be disabled\n(and not compiled in). This is what you typically want in a release build.\n\n### Logging interface\n\n4 Macros are used for logging: `LOG_INIT`, `LOG`; `LOGS` and `FLOGS`:\n\n#### LOG_INIT\n\nThe `LOG_INIT(target)` macro initializes the logging. It takes a pointer to a\nsubclass of the [Print](https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/Print.h)\nclass as argument, which specifies the log target, e.g. `LOG_INIT(\u0026Serial)`. No\nlogging will happen until `LOG_INIT` is called. If needed, call\n`LOG_INIT(nullptr)` to turn off logging during runtime.\n\n#### LOG(fmt, ...)\n\nUse the `LOG(fmt, ...)` macro to log in a\n[printf-like](http://www.cplusplus.com/reference/cstdio/printf/) fashion. The\n`fmt` format string will automatically be stored in flash memory using the\n`F()` macro to reduce amount of SRAM being used.\n\n#### LOGS(s)\n\nUse the `LOGS(s)` (the *S* stands for *simple*) macro, to directly log out the\ngiven value using the log target's `print` method.\n\n#### FLOGS(s)\n\nUse the `FLOGS(s)` (the added *F* stands for *flash*) macro, to log out the\ngiven value (now stored in Flash memory) using the log target's `print` method.\n\n## A word on log levels\n\nlog4arduino does not support log levels. This lib is not meant for enterprise\ndevelopment and we have to keep the memory footprint low. YAGNI.\n\n## Author\n\n(C) Copyright 2017-2022 by Jan Delgado\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjandelgado%2Flog4arduino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjandelgado%2Flog4arduino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjandelgado%2Flog4arduino/lists"}