Giter Club home page Giter Club logo

debuglog's Introduction

Top Langs github stats

debuglog's People

Contributors

erezbinyamin avatar hideakitai avatar tpanajott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

debuglog's Issues

[QUESTION/FEATURE REQUEST] Cutsom log format - add timestamp

Is it possible to add a custom log format? Specifically I'm wanting to prefix each log with a timestamp, either millis() or YYMMDDHHMMSS if RTC is available.

Instead of implementing the time handling internally, probably best bet is a custom format callback or something?

Does anything like this exists?

If not would you be interested in PR? If so any suggestion on best place to implement?

LOG_ERROR' was not declared in this scope

hello ,i just tried your librarie but there is an error in your example
tested with ESP8266 wemos D1 mini

G:\Documents\Arduino\libraries\Debug\example\example.ino: In function 'void setup()':
example:11:32: error: 'LOG_ERROR' was not declared in this scope
   LOG_ERROR("this is error log");
                                ^
example:12:36: error: 'LOG_WARNING' was not declared in this scope
   LOG_WARNING("this is warning log");
                                    ^
example:13:36: error: 'LOG_VERBOSE' was not declared in this scope
   LOG_VERBOSE("this is verbose log");
                                    ^
example:15:17: error: 'Debug' has not been declared
   LOG_SET_LEVEL(Debug::LogLevel::WARNING);
                 ^
example:15:41: error: 'LOG_SET_LEVEL' was not declared in this scope
   LOG_SET_LEVEL(Debug::LogLevel::WARNING);
                                         ^
example:22:17: error: 'Debug' has not been declared
   LOG_SET_LEVEL(Debug::LogLevel::ERROR);
                 ^
example:29:17: error: 'Debug' has not been declared
   LOG_SET_LEVEL(Debug::LogLevel::NONE);
                 ^
example:39:16: error: 'ASSERT' was not declared in this scope
   ASSERT(x != 1); // if assertion failed, Serial endlessly prints message
                ^
exit status 1
'LOG_ERROR' was not declared in this scope

LogPrecision does not name a type

Hello,

I am trying to compile a small C++ program for testing hideakitai/MsgPack. However, I get the following error:

DebugLog/DebugLog.h:22:39: error: ‘LogPrecision’ in namespace ‘arx::debug’ does not name a type
   22 | using DebugLogPrecision = arx::debug::LogPrecision;
      |                                       ^~~~~~~~~~~~

LogPrecision is used here:

using DebugLogPrecision = arx::debug::LogPrecision;

But if ARDUINO is not defined, LogPrecision is not available:

#ifdef ARDUINO
enum class LogPrecision {
ZERO,
ONE,
TWO,
THREE,
FOUR,
FIVE,
SIX,
SEVEN,
EIGHT,
};
#endif

I suggest replacing line 22 with:

#ifdef ARDUINO
using DebugLogPrecision = arx::debug::LogPrecision;
#endif

LOG_ATTACH_FS_AUTO with SD-Card do not work

When i use the example with an SD-Card the LOG_ATTACH_FS_AUTO() creates a file with size equal to available bytes left on SD-Card.
the content of the file seems to be random.

Version 0.6.0.

When using Verion 0.5.1 (and different interface ) it works fine.

DebugLog.cpp

//to avoid multiple declaration issue

#include <DebugLog.h>

namespace arx {
namespace debug {

#ifdef ARDUINO
  Stream* stream {&Serial};
#endif

#ifdef ARDUINO      
Logger* logger {nullptr};
bool b_auto_save {false};
bool b_only_sd {false};
LogLevel log_level = LogLevel::VERBOSE;

#endif
}

}

and extern these variables in .h file

how to format floating point values

I am a noob in C++ and have a question regarding logging floats with DebugLog.
The floats are always in a format with 2 decimals but i need up to 6 decimals.
Is there a ways to change the format of the output of floats?

ESP8266 problem

Hello,
I try your library, is awsome, but I have trouble to run it on ESP8266 (D1 mini V2). I use PlatformIO. When I comment or change second LOG to PRINT it work with no error. I am confused. This code do exception (on ESP32 it work with no problem).
main.cpp:

#include <DebugLog.h>

void setup() {
    Serial.begin(115200);
    delay(2000);
    LOG_SET_LEVEL(DebugLogLevel::LVL_TRACE);
    LOG_DEBUG("Program start");
}

void loop() {
    LOG_ERROR("Main");
}

Exception:

Exception (3):
epc1=0x4000bf64 epc2=0x00000000 epc3=0x00000000 excvaddr=0x4023b017 depc=0x00000000

LoadStoreError: Processor internal physical address or data error during load or store
  excvaddr=0x4023b017 in etharp_output at ??:?

>>>stack>>>

ctx: cont
sp: 3ffffd70 end: 3fffffc0 offset: 0190
3fffff00:  00000007 00000001 3fffff3c 4020197c
3fffff10:  00000000 4023b017 3fffff3c 402019b5
3fffff20:  00000007 3ffee510 3fffff90 4020123f
3fffff30:  00000000 3ffee500 00000000 00000020
3fffff40:  7070632e 01000000 00000000 3ffee500
3fffff50:  00000000 00000000 3ffee518 00000000
3fffff60:  4023b017 3ffe88ce 3ffee518 402019b5
3fffff70:  40202519 00000000 3ffee510 3ffee5c4  
3fffff80:  3fffdad0 00000000 3ffee510 4020138c
3fffff90:  3ffef384 0015001f 88000000 feefeffe
3fffffa0:  feefeffe feefeffe 3ffee5b0 40201f84
3fffffb0:  feefeffe feefeffe 3ffe85d8 40100c25
<<<stack<<<

0x4020197c in String::copy(char const*, unsigned int) at ??:?
0x4023b017 in etharp_output at ??:?
0x402019b5 in String::String(char const*) at ??:?
0x4020123f in arx::debug::Manager::generate_header(arx::debug::LogLevel, char const*, int, char const*) const at ??:?
0x4023b017 in etharp_output at ??:?
0x402019b5 in String::String(char const*) at ??:?
0x40202519 in __delay at ??:?
0x4020138c in setup at ??:?
0x40201f84 in loop_wrapper() at core_esp8266_main.cpp:?
0x40100c25 in cont_wrapper at ??:?

Second decoder (Arduino IDE):

Exception 3: LoadStoreError: Processor internal physical address or data error during load or store
PC: 0x4000bf64
EXCVADDR: 0x4023b007

Decoding stack results
0x40201970: String::copy(char const*, unsigned int) at C:\\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\WString.cpp line 225
0x402019a9: String::String(char const*) at C:\\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\WString.cpp line 41
0x4020123b: arx::debug::Manager::generate_header(arx::debug::LogLevel, char const*, int, char const*) const at C:\\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266/WString.h line 373
0x402019a9: String::String(char const*) at C:\\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\WString.cpp line 41
0x40202505: __delay(unsigned long) at C:\\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_wiring.cpp line 55
0x4020138a: setup() at C:\\Documents\Arduino\libraries\DebugLog/DebugLog/Manager.h line 121
0x40201f70: loop_wrapper() at C:\\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\cores\esp8266\core_esp8266_main.cpp line 198

PlatformIo.ini:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 115200
monitor_filters = esp8266_exception_decoder
lib_deps = 
    hideakitai/DebugLog

Reduce code footprint when log level is decreased.

#define LOG_ERROR(...) DebugLog::Manager::get().log(arx::debug::LogLevel::LVL_ERROR, LOG_PREAMBLE, __VA_ARGS__)

TLDR;

It'd be nice if using less verbose logging actually build a smaller binary.

Explanation

In the current state if the log level is set to ERROR then only LOG_ERROR messages will be printed, but all of the other code for the other log messages will still be executed. It just will eventually not print when the log function is called. Macros like #ifdef could be used to exculde unused LOG_XXXX messages.

The change would be to simply add some code to DebugLogEnable.h

#if defined(DEBUGLOG_DEFAULT_LOG_LEVEL_ERROR)
  #define LOG_WARN(...)
  #define LOG_INFO(...)
  #define LOG_DEBUG(...)
  #define LOG_TRACE(...)
#elif defined(DEBUGLOG_DEFAULT_LOG_LEVEL_WARN)
  #define LOG_INFO(...)
  #define LOG_DEBUG(...)
  #define LOG_TRACE(...)
#elif defined(DEBUGLOG_DEFAULT_LOG_LEVEL_INFO)
  #define LOG_DEBUG(...)
  #define LOG_TRACE(...)
#elif defined(DEBUGLOG_DEFAULT_LOG_LEVEL_DEBUG)
  #define LOG_TRACE(...)
#endif

Esp32-s3 compilation error, with a certain #include order

Platformio,
[env:esp32-s3-devkitc-1] platform = espressif32 board = esp32-s3-devkitc-1 framework = arduino monitor_speed = 115200 build_flags = -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1

`Processing esp32-s3-devkitc-1 (platform: espressif32; board: esp32-s3-devkitc-1; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1.html
PLATFORM: Espressif 32 (6.1.0) > Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:

  • framework-arduinoespressif32 @ 3.20007.0 (2.0.7)
  • tool-esptoolpy @ 1.40500.0 (4.5.0)
  • toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
  • toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
    LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 39 compatible libraries
    Scanning dependencies...
    Dependency Graph
    |-- ESPAsyncWebServer-esphome @ 3.0.0
    |-- MsgPack @ 0.3.19
    |-- SPI @ 2.0.0
    |-- TFT_eSPI @ 2.5.31
    Building in release mode
    Compiling .pio/build/esp32-s3-devkitc-1/src/main.cpp.o
    In file included from src/main.cpp:3:
    .pio/libdeps/esp32-s3-devkitc-1/TFT_eSPI/TFT_eSPI.h:975:8: warning: #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available! [-Wcpp]
    #warning >>>>------>> TOUCH_CS pin not defined, TFT_eSPI touch functions will not be available!
    ^~~~~~~
    In file included from .pio/libdeps/esp32-s3-devkitc-1/MsgPack/MsgPack/util/DebugLog/DebugLog.h:17,
    from .pio/libdeps/esp32-s3-devkitc-1/MsgPack/MsgPack.h:5,
    from src/main.cpp:5:
    .pio/libdeps/esp32-s3-devkitc-1/MsgPack/MsgPack/util/DebugLog/DebugLog/Manager.h: In member function 'void arx::debug::Manager::attach(FsType&, const String&, const FileMode&, bool)':
    .pio/libdeps/esp32-s3-devkitc-1/MsgPack/MsgPack/util/DebugLog/DebugLog/Manager.h:76:47: error: 'File' was not declared in this scope
    logger = new FsFileLogger<FsType, File>(s, path, mode);
    ^~~~
    .pio/libdeps/esp32-s3-devkitc-1/MsgPack/MsgPack/util/DebugLog/DebugLog/Manager.h:76:47: note: suggested alternative:
    In file included from .pio/libdeps/esp32-s3-devkitc-1/TFT_eSPI/Processors/TFT_eSPI_ESP32_S3.h:152,
    from .pio/libdeps/esp32-s3-devkitc-1/TFT_eSPI/TFT_eSPI.h:96,
    from src/main.cpp:3:
    /home/andriy/.platformio/packages/framework-arduinoespressif32/libraries/FS/src/FS.h:47:7: note: 'fs::File'
    class File : public Stream
    ^~~~
    In file included from .pio/libdeps/esp32-s3-devkitc-1/MsgPack/MsgPack/util/DebugLog/DebugLog.h:17,
    from .pio/libdeps/esp32-s3-devkitc-1/MsgPack/MsgPack.h:5,
    from src/main.cpp:5:
    .pio/libdeps/esp32-s3-devkitc-1/MsgPack/MsgPack/util/DebugLog/DebugLog/Manager.h:76:51: error: template argument 2 is invalid
    logger = new FsFileLogger<FsType, File>(s, path, mode);
    ^
    *** [.pio/build/esp32-s3-devkitc-1/src/main.cpp.o] Error 1`

`#include "Arduino.h"
#include <SPI.h>
#include <TFT_eSPI.h>
#include <ESPAsyncWebServer.h>
#include <MsgPack.h>

void setup() {
}

void loop() {

}`

Strange behavior log in two serial data ports events

When a log is output from two serial data ports events, the data is mixed and partially discarded.
Example log
2020-10-15 12:56:57.250|VERBOSE|CommandProcessor.cpp|65|Execute|cmd:T02020-10-15 12:56:57.256|VERBOSE|TATransport.cpp|250|RetranslatePSCommand|Enter

The expected log
2020-10-15 12:56:57.250|VERBOSE|TATransport.cpp|171|SeparatePCCommands|Enter
2020-10-15 12:56:57.256|VERBOSE|CommandProcessor.cpp|65|Execute|cmd:T01,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.