romix123 / P1-wifi-gateway

21 stars 9 forks source link

Added Configurable logger #11

Closed ronnievdc closed 9 months ago

ronnievdc commented 10 months ago

Uses ArdionoLog library for logging.

It can send logs to:

All debug statements are replaced with Log.verbose. Later different levels of logging can be used.

* 0 - LOG_LEVEL_SILENT     no output 
* 1 - LOG_LEVEL_FATAL      fatal errors 
* 2 - LOG_LEVEL_ERROR      all errors  
* 3 - LOG_LEVEL_WARNING    errors, and warnings 
* 4 - LOG_LEVEL_NOTICE     errors, warnings and notices 
* 5 - LOG_LEVEL_TRACE      errors, warnings, notices & traces 
* 6 - LOG_LEVEL_VERBOSE    all 

String can be formatted with variables:

* %s    display as string (char*)
* %S    display as string from flash memory (__FlashStringHelper* or char[] PROGMEM)
* %c    display as single character
* %C    display as single character or as hexadecimal value (prefixed by `0x`) if not a printable character
* %d    display as integer value
* %l    display as long value
* %u    display as unsigned long value
* %x    display as hexadecimal value
* %X    display as hexadecimal value prefixed by `0x` and leading zeros
* %b    display as binary number
* %B    display as binary number, prefixed by `0b`
* %t    display as boolean value "t" or "f"
* %T    display as boolean value "true" or "false"
* %D,%F display as double value
* %p    display a  printable object 

NOTE: The published ArdionoLog version 1.1.1 is broken (does not remove logging from build), therefore the newer (unreleased) commit on Github is used.

romix123 commented 10 months ago

Nice

On 4 Feb 2024, at 21:55, Ronnie @.***> wrote:

Uses ArdionoLog https://reference.arduino.cc/reference/en/libraries/arduinolog/ library for logging.

It can send logs to:

NULL (disables logging and removes if from the build to reduce the size) Serial Telnet (port 24, with up to 5 active sessions) - Serial will be used when there is no active connection MQTT server (p1wifi/logging topic) - Serial will be used when there is no active connection All debug statements are replaced with Log.verbose. Later different levels of logging can be used.

  • 0 - LOG_LEVEL_SILENT no output

  • 1 - LOG_LEVEL_FATAL fatal errors

  • 2 - LOG_LEVEL_ERROR all errors

  • 3 - LOG_LEVEL_WARNING errors, and warnings

  • 4 - LOG_LEVEL_NOTICE errors, warnings and notices

  • 5 - LOG_LEVEL_TRACE errors, warnings, notices & traces

  • 6 - LOG_LEVEL_VERBOSE all String can be formatted with variables:

  • %s display as string (char*)

  • %S display as string from flash memory (__FlashStringHelper* or char[] PROGMEM)

  • %c display as single character

  • %C display as single character or as hexadecimal value (prefixed by 0x) if not a printable character

  • %d display as integer value

  • %l display as long value

  • %u display as unsigned long value

  • %x display as hexadecimal value

  • %X display as hexadecimal value prefixed by 0x and leading zeros

  • %b display as binary number

  • %B display as binary number, prefixed by 0b

  • %t display as boolean value "t" or "f"

  • %T display as boolean value "true" or "false"

  • %D,%F display as double value

  • %p display a printable object NOTE: The published ArdionoLog version 1.1.1 is broken (does not remove logging from build), therefore the newer (unreleased) commit on Github is used.

You can view, comment on, or merge this pull request online at:

https://github.com/romix123/P1-wifi-gateway/pull/11

Commit Summary

3acb526 https://github.com/romix123/P1-wifi-gateway/pull/11/commits/3acb5261a634597ea811f94569446161de6af6e0 Added Configurable logger File Changes (18 files https://github.com/romix123/P1-wifi-gateway/pull/11/files) M platformio.ini https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-4446afd728a4f34cbcddc306a9cb6be845d1a61c216076a295683bcc9c106724 (6) M src/JSON.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-2b07d1e6976bc5f1e3e20800a1dbb7af74165b98c189db293e326c59b20e4577 (26) M src/MQTT.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-3953519fceee94e19a20874391631af210d80b1132a54eb28b3262946cf449ae (66) M src/TELNET.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-c48950e273aea14336c1b17c98b30e19355d30b339632e58046ec7d60c048284 (57) M src/decoder.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-cfd30276dde9114fc2c8a2b9cd71633b84398bc4e8dfaa40db221c394ae907da (148) M src/functions.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-aa3d5bf2af524e9bda5fe0506b3a2f1e973aaa38a833d41073935b2d1d223157 (102) M src/graph.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-af4cf636d93537a19c81a7a4a2b87c6cb689718c92bce1fd0ab763a86d7f31f4 (58) A src/logger/MQTTPrinter.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-0d45652f7533328506cb0b4f07f06b61848845d5a49739a09932be3e20d18f02 (42) A src/logger/TelnetPrinter.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-553111cb254378ef1595f2c92c9bb2fdcb49c2ea7bbe705edc6e8178f54548f4 (96) A src/logger/logger.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-d98cf8fbd391a60901aeda01985456a65a9d9527250e72465638c3cd0bc1ca68 (49) M src/logging.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-21abb6b14af1e9330a6f0c89a87231035a439248c556ef5e110eb0617b88a1f4 (26) M src/main.cpp https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-34d21af3c614ea3cee120df276c9c4ae95053830d7f1d3deaf009a4625409ad2 (216) M src/newMQTT.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-b7a40cc5863d7b44de4abb039929447fb2f8ac61adc051c8283d3b3393efb18b (46) M src/p1debug.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-33e14b932e4d4cbfa71356bebcdbc39a1814aef4e6f9300fb7e56e45c60a12e9 (74) M src/prototypes.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-068da4785a53bdf7affcd43cbdf5b105aea4328fecfdfdfe7dae0eb8daa16129 (2) M src/webserver.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-a93ea68cbc10b72e93ba352168f3ced4b4cade9d99a3239dec30ccc1c32a452a (34) M src/webserverNL.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-24b6f7f9c9302fc75b192e00c554a09bb5b1a2e159b0a46c3930bcb5bf7be204 (30) M src/wifi_functions.h https://github.com/romix123/P1-wifi-gateway/pull/11/files#diff-1b30e8f2033c0cdc2f9dd30da6f304a554ac9b2b9b328b05ecc3e323459d37ef (56) Patch Links:

https://github.com/romix123/P1-wifi-gateway/pull/11.patch https://github.com/romix123/P1-wifi-gateway/pull/11.diff — Reply to this email directly, view it on GitHub https://github.com/romix123/P1-wifi-gateway/pull/11, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANPIKVE5Y2AB7XCLQQAX2TYR7YSXAVCNFSM6AAAAABCZEJWECVHI2DSMVQWIX3LMV43ASLTON2WKOZSGEYTOMZQGAYTENA. You are receiving this because you are subscribed to this thread.

ronnievdc commented 9 months ago

Fixed a few errors converting debug to Log statements.

Added colors to different Log levels. image