{"id":15011948,"url":"https://github.com/thijse/arduino-log","last_synced_at":"2025-10-06T05:31:16.825Z","repository":{"id":17892816,"uuid":"82773003","full_name":"thijse/Arduino-Log","owner":"thijse","description":"Simple application log library. supporting multiple log levels, custom output  \u0026 flash memory support.","archived":false,"fork":true,"pushed_at":"2024-03-07T14:10:02.000Z","size":443,"stargazers_count":166,"open_issues_count":9,"forks_count":82,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-10-01T04:05:38.998Z","etag":null,"topics":["arduino","arduino-library","avr","esp32","esp8266","logging","logging-library","platformio"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mrRobot62/Arduino-logging-library","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thijse.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-22T07:15:15.000Z","updated_at":"2024-09-05T11:00:32.000Z","dependencies_parsed_at":"2023-02-09T22:25:10.746Z","dependency_job_id":null,"html_url":"https://github.com/thijse/Arduino-Log","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thijse%2FArduino-Log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thijse%2FArduino-Log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thijse%2FArduino-Log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thijse%2FArduino-Log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thijse","download_url":"https://codeload.github.com/thijse/Arduino-Log/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235503751,"owners_count":19000700,"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","arduino-library","avr","esp32","esp8266","logging","logging-library","platformio"],"created_at":"2024-09-24T19:41:55.721Z","updated_at":"2025-10-06T05:31:11.322Z","avatar_url":"https://github.com/thijse.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"![ArduinoLog logo](/Images/logo.png?raw=true )\nArduinoLog - C++ Log library for Arduino devices\n====================\n[![Build Status](https://travis-ci.org/thijse/Arduino-Log.svg?branch=master)](https://travis-ci.org/thijse/Arduino-Log)\n[![License](https://img.shields.io/badge/license-MIT%20License-blue.svg)](http://doge.mit-license.org)\n\n*An minimalistic Logging framework for Arduino-compatible embedded systems.*\n\nArduinoLog is a minimalistic framework to help the programmer output log statements to an output of choice, fashioned after extensive logging libraries such as log4cpp ,log4j and log4net. In case of problems with an application, it is helpful to enable logging so that the problem can be located. ArduinoLog is designed so that log statements can remain in the code with minimal performance cost. In order to facilitate this the loglevel can be adjusted, and (if your code is completely tested) all logging code can be compiled out. \n\n## Features\n\n* Different log levels (Error, Info, Warn, Debug, Verbose )\n* Supports multiple variables\n* Supports formatted strings \n* Supports formatted strings from flash memory\n* Fixed memory allocation (zero malloc)\n* MIT License\n\n## Tested for \n\n* All Arduino boards (Uno, Due, Mini, Micro, Yun...)\n* ESP8266\n* ESP32\n\n## Downloading\n\nThis package has been published to the Arduino \u0026 PlatformIO package managers, but you can also download it from GitHub. \n\n- By directly loading fetching the Archive from GitHub: \n 1. Go to [https://github.com/thijse/Arduino-Log](https://github.com/thijse/Arduino-Log)\n 2. Click the DOWNLOAD ZIP button in the panel on the\n 3. Rename the uncompressed folder **Arduino-Log-master** to **Arduino-Log**.\n 4. You may need to create the libraries subfolder if its your first library.  \n 5. Place the **Arduino-Log** library folder in your **\u003carduinosketchfolder\u003e/libraries/** folder. \n 5. Restart the IDE.\n 6. For more information, [read this extended manual](http://thijs.elenbaas.net/2012/07/installing-an-arduino-library/)\n\n\n## Quick start\n\n```c++\n    Serial.begin(9600);\n    \n    // Initialize with log level and log output. \n    Log.begin   (LOG_LEVEL_VERBOSE, \u0026Serial);\n    \n    // Start logging text and formatted values\n    Log.errorln (  \"Log as Error   with binary values             : %b, %B\"    , 23  , 345808);\n    Log.warning (F(\"Log as Warning with integer values from Flash : %d, %d\"CR) , 34  , 799870);\n```\n\nSee [Log-basic.ino](examples/Log-basic/Log-basic.ino) example\n\n\n## Usage\n\n### Initialisation\n\nThe log library needs to be initialized with the log level of messages to show and the log output. The latter will often be the Serial interface.\nOptionally, you can indicate whether to show the log type (error, debug, etc) for each line.\n\n```\nbegin(int level, Print* logOutput, bool showLevel)\nbegin(int level, Print* logOutput)\n```\n\nThe loglevels available are\n\n```\n* 0 - LOG_LEVEL_SILENT     no output \n* 1 - LOG_LEVEL_FATAL      fatal errors \n* 2 - LOG_LEVEL_ERROR      all errors  \n* 3 - LOG_LEVEL_WARNING    errors, and warnings \n* 4 - LOG_LEVEL_NOTICE     errors, warnings and notices \n* 5 - LOG_LEVEL_TRACE      errors, warnings, notices \u0026 traces \n* 6 - LOG_LEVEL_VERBOSE    all \n```\n\nexample\n\n```\nLog.begin(LOG_LEVEL_ERROR, \u0026Serial, true);\n```\n\nif you want to fully remove all logging code, uncomment `#define DISABLE_LOGGING` in `ArduinoLog.h`, this may significantly reduce your sketch/library size.\n\n### Log events\n\nThe library allows you to log on different levels by the following functions\n\n```c++\nvoid fatal   (const char *format, va_list logVariables); \nvoid error   (const char *format, va_list logVariables);\nvoid warning (const char *format, va_list logVariables);\nvoid notice  (const char *format, va_list logVariables);\nvoid trace   (const char *format, va_list logVariables);\nvoid verbose (const char *format, va_list logVariables);\n```\n\nwhere the format string can be used to format the log variables\n\n```\n* %s\tdisplay as string (char*)\n* %S    display as string from flash memory (__FlashStringHelper* or char[] PROGMEM)\n* %c\tdisplay as single character\n* %C    display as single character or as hexadecimal value (prefixed by `0x`) if not a printable character\n* %d\tdisplay as integer value\n* %l\tdisplay as long value\n* %u\tdisplay as unsigned long value\n* %x\tdisplay as hexadecimal value\n* %X\tdisplay as hexadecimal value prefixed by `0x` and leading zeros\n* %b\tdisplay as binary number\n* %B\tdisplay as binary number, prefixed by `0b`\n* %t\tdisplay as boolean value \"t\" or \"f\"\n* %T\tdisplay as boolean value \"true\" or \"false\"\n* %D,%F display as double value\n* %p    display a  printable object \n```\n\n Newlines can be added using the `CR` keyword or by using the `...ln` version of each of the log functions.  The difference when using the `...ln` is that the newline is placed after suffix, and only a single newline can be added. Some terminals prefer `NL` (New line).\n\n### Examples\n\n```c++\nLog.fatal     (F(\"Log as Fatal   with string value from Flash   : %s\"CR    ) , \"value\"     );\nLog.errorln   (  \"Log as Error   with binary values             : %b, %B\"    , 23  , 345808);\nLog.warning   (F(\"Log as Warning with integer values from Flash : %d, %d\"CR) , 34  , 799870);\nLog.notice    (  \"Log as Notice  with hexadecimal values        : %x, %X\"CR  , 21  , 348972);\nLog.trace     (  \"Log as Trace   with Flash string              : %S\"CR    ) , F(\"value\")  );\nLog.verboseln (F(\"Log as Verbose with bool value from Flash     : %t, %T\"  ) , true, false );\n```\n\n### Disable library\n\n(if your code is completely tested) all logging code can be compiled out. Do this by uncommenting  \n```c++\n#define DISABLE_LOGGING \n```\nin `Logging.h`. This may significantly reduce your project size.\n\n\n## Advanced usage\n\nAdvanced features are demonstrated in [Log-advanced](examples/Log-advanced/Log-advanced.ino) example.\n\n### Displaying a printable object\n\nSome Arduino objects are printable. That is, they implement the `Printable` interface and are able for format their own representation\nAs an example, the IPadress object is printable:\n\n```c++\nIPAddress   ipAddress(192, 168, 0, 1);\nLog.verboseln (\"ip address   : %p\", ipAddress);\n```\n\n[this example](https://forum.arduino.cc/t/printable-classes/438816) shows how to make your own classes printable\n \n ### Storing messages in Flash memory\n\nFlash strings log variables can be stored and reused at several places to reduce final hex size.\n\n```c++\nconst __FlashStringHelper * logAs = F(\"Log as\");\nLog.fatal   (F(\"%S Fatal with string value from Flash   : %s\"CR    ) , logAs, \"value\"     );\nLog.error   (  \"%S Error with binary values             : %b, %B\"CR  , logAs, 23  , 345808);\n```\n\nIf you want to declare that string globally (outside of a function), you will need to use the PROGMEM macro instead.\n\n```c++\nconst char LOG_AS[] PROGMEM = \"Log as \";\n\nvoid logError() {\n    Log.error   (  \"%S Error with binary values : %b, %B\"CR  , PSTRPTR(LOG_AS), 23  , 345808);\n}\n```\n\n### Custom logging format\n\nYou can modify your logging format by defining a custom prefix \u0026 suffix for each log line. For example:\n```c++\nvoid printPrefix(Print* _logOutput, int logLevel) {\n    printTimestamp(_logOutput);\n    printLogLevel (_logOutput, logLevel);\n}\n```\nwill result in log timestamps very similar to e.g. NLOG:\n```\n00:47:51.432 VERBOSE Message to be logged\n```\n\n## Credit\n\nBased on library by \n* [Bernd Klein](https://github.com/mrRobot62)  \n\nBugfixes \u0026 features by\n* [rahuldeo2047](https://github.com/rahuldeo2047)\n* [NOX73](https://github.com/NOX73)\n* [Dave Hylands](https://github.com/dhylands)\n* [Jos Hanon](https://github.com/Josha)\n* [Bertrand Lemasle](https://github.com/blemasle)\n* [Mikael Falkvidd](https://github.com/mfalkvidd)\n* [Rowan Goemans](https://github.com/rowanG077)\n* [Nils Bokermann](https://github.com/sanddorn)\n* [Florian](https://github.com/1technophile)\n* [wrong-kendall](https://github.com/wrong-kendall)\n* [bitli](https://github.com/bitli)\n* [ChristianBauerAMDC](https://github.com/ChristianBauerAMDC)\n\n## On using and modifying libraries\n\n- [http://www.arduino.cc/en/Main/Libraries](http://www.arduino.cc/en/Main/Libraries)\n- [http://www.arduino.cc/en/Reference/Libraries](http://www.arduino.cc/en/Reference/Libraries) \n\n## Copyright\n\nArduinoLog (Copyright © 2017,2018, 2019, 2021) is provided under MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthijse%2Farduino-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthijse%2Farduino-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthijse%2Farduino-log/lists"}