Files
espurna/code/espurna/debug.h
Maxim Prokhorov b167d61615 debug: refactoring & remove special case for PROGMEM
Don't use variable length array and remove `debugSend_P`, directly give the format to `vsnprintf_P`.

Common functions moved into namespace debug { ... }
Module functions moved into namespace { ... }

Provide len argument to most outputs, so it's calculated exactly once.
Early checks for nullptr and zero length.

Fix include order once again, try not to depend on config in header and
only use it in the actual .cpp code.

Still involves strlen for flash strings, but that needs to be addressed by using a custom type like:
```
struct PstrWithLength {
    const char* const ptr;
    size_t size;
};
```
And define PSTR macro to return:
```
PstrWithLength{&__pstr__[0], sizeof(__pstr__)};`
```
(and, probably, for any `const char (&fixed)[Size]` arrays as well)
2021-08-11 13:58:24 +03:00

31 lines
452 B
C++

/*
DEBUG MODULE
*/
#pragma once
#include <cstdint>
class PrintRaw;
class PrintHex;
enum class DebugLogMode : int {
Disabled = 0,
Enabled = 1,
SkipBoot = 2
};
bool debugLogBuffer();
void debugWebSetup();
void debugConfigure();
void debugConfigureBoot();
void debugSetup();
void debugSendRaw(const char* line, bool timestamp = false);
void debugSendBytes(const uint8_t* bytes, size_t size);
void debugSend(const char* format, ...);