{"id":31588595,"url":"https://github.com/esptoolkit/esp-logger","last_synced_at":"2025-10-06T02:11:53.310Z","repository":{"id":315248747,"uuid":"1057789472","full_name":"ESPToolKit/esp-logger","owner":"ESPToolKit","description":"A lightweight, configurable logging utility for ESP32 projects.","archived":false,"fork":false,"pushed_at":"2025-09-25T09:26:26.000Z","size":189,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-25T11:30:53.938Z","etag":null,"topics":["arduino","async","esp32","idf","logging","pioarduino","platformio","sync"],"latest_commit_sha":null,"homepage":"https://esptoolkitfrontend.onrender.com","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/ESPToolKit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-16T07:59:37.000Z","updated_at":"2025-09-25T09:25:14.000Z","dependencies_parsed_at":"2025-09-17T15:35:58.644Z","dependency_job_id":null,"html_url":"https://github.com/ESPToolKit/esp-logger","commit_stats":null,"previous_names":["esptoolkit/esp-logger"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ESPToolKit/esp-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ESPToolKit%2Fesp-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ESPToolKit%2Fesp-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ESPToolKit%2Fesp-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ESPToolKit%2Fesp-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ESPToolKit","download_url":"https://codeload.github.com/ESPToolKit/esp-logger/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ESPToolKit%2Fesp-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278547821,"owners_count":26004775,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","async","esp32","idf","logging","pioarduino","platformio","sync"],"created_at":"2025-10-06T02:11:12.406Z","updated_at":"2025-10-06T02:11:53.305Z","avatar_url":"https://github.com/ESPToolKit.png","language":"C++","funding_links":["https://ko-fi.com/esptoolkit"],"categories":[],"sub_categories":[],"readme":"# ESP Logger\n\n[![CI](https://github.com/ESPToolKit/esp-logger/actions/workflows/ci.yml/badge.svg)](https://github.com/ESPToolKit/esp-logger/actions/workflows/ci.yml)\n[![Release](https://img.shields.io/github/v/release/ESPToolKit/esp-logger?sort=semver)](https://github.com/ESPToolKit/esp-logger/releases)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.md)\n\nA lightweight, configurable logging utility for ESP32 projects.\nIt combines formatted log APIs, in-RAM batching, and optional background syncing\nso you can integrate storage or telemetry pipelines without blocking application code.\n\n## Features\n- Familiar `debug`/`info`/`warn`/`error` helpers with `printf` formatting semantics.\n- Configurable runtime behavior: batching, FreeRTOS core/stack/priority, and global console log level.\n- Optional background sync task plus manual `sync()` for deterministic flushes.\n- `onSync` callback with a vector of structured `Log` entries for custom persistence.\n- Helpers to fetch every buffered log or just the most recent entries at any time.\n- Console output automatically routed through the ESP-IDF `ESP_LOGx` macros.\n\n## Getting Started\n1. Install the library (drop it into `lib/` for PlatformIO or `libraries/` for the Arduino IDE).\n2. Include the umbrella header:\n\n```cpp\n#include \u003cESPLogger.h\u003e\n```\n\n3. Initialise the logger (optionally overriding the defaults):\n\n```cpp\n#include \u003cESPLogger.h\u003e\n\nvoid setup() {\n    Serial.begin(115200);\n\n    // Quick start: call logger.init(); with no arguments to use the default config.\n    LoggerConfig config;\n    config.syncIntervalMS = 5000;   // flush to callback every 5 seconds\n    config.maxLogInRam = 100;       // keep 100 entries before forcing a flush\n    config.consoleLogLevel = LogLevel::Info;  // suppress debug traces on console\n\n    logger.init(config);\n\n    logger.onSync([](const std::vector\u003cLog\u003e\u0026 logs) {\n        // Persist logs to flash, send over Wi-Fi, etc.\n    });\n\n    logger.info(\"INIT\", \"Logger initialised with %u entries\", config.maxLogInRam);\n}\n\nvoid loop() {\n    logger.debug(\"LOOP\", \"Loop iteration at %lu ms\", static_cast\u003cunsigned long\u003e(millis()));\n    delay(1000);\n}\n```\n\n## Configuration Reference\n`LoggerConfig` exposes the following knobs:\n\n| Field | Default | Description |\n| --- | --- | --- |\n| `syncIntervalMS` | `5000` | Period between automatic flushes. Ignored when `enableSyncTask` is `false`. |\n| `stackSize` | `4096` | Stack size (words) for the sync task. |\n| `coreId` | `LoggerConfig::any` | CPU core affinity for the sync task. |\n| `maxLogInRam` | `100` | Maximum entries retained in RAM; when the buffer is full the oldest entry is discarded. |\n| `taskPriority` | `1` | FreeRTOS priority for the sync task. |\n| `consoleLogLevel` | `LogLevel::Debug` | Minimum level printed to the console. Lower levels remain buffered. |\n| `enableSyncTask` | `true` | Disable to opt out of the background task and call `logger.sync()` manually. |\n\n### Changing the Log Level at Runtime\n\n```cpp\nlogger.setLogLevel(LogLevel::Warn);  // only warn/error logs reach the console\n```\n\nThe new level is stored on the logger and in the active `LoggerConfig` snapshot returned by `currentConfig()`.\n\n### Manual Syncing \u0026 Retrieval\n\n```cpp\n// Force a flush when using enableSyncTask = false\nlogger.sync();\n\n// Fetch all buffered entries\nstd::vector\u003cLog\u003e allLogs = logger.getAllLogs();\n\n// Fetch the last N entries\nauto latest = logger.getLastLogs(10);\n```\n\n## Examples\nTwo sketches under the `examples/` folder demonstrate common setups:\n- `examples/basic_usage/basic_usage.ino` – Minimal configuration and periodic logging.\n- `examples/custom_sync/custom_sync.ino` – Manual syncing with a custom persistence callback.\n\nUpload one of the sketches to your ESP32 board to see the logger in action.\n\n## License\nMIT\n\n## ESPToolKit\n\n- Check out other libraries under ESPToolKit: https://github.com/orgs/ESPToolKit/repositories\n- Join our discord server at: https://discord.gg/WG8sSqAy\n- If you like the libraries, you can support me at: https://ko-fi.com/esptoolkit\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesptoolkit%2Fesp-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fesptoolkit%2Fesp-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fesptoolkit%2Fesp-logger/lists"}