esp-cpp / espp

C++ components for ESP
https://esp-cpp.github.io/espp/
MIT License
30 stars 9 forks source link

feat(logger): allow compiling out `espp::Logger` levels / verbosity to reduce size #270

Closed finger563 closed 3 months ago

finger563 commented 3 months ago

Description

Motivation and Context

As a system moves to production (or reaches the end of its partition size 😅), it may be necessary to optimize out log levels that are not being used so they do not contribute to code size.

How has this been tested?

Building and running logger/example on a QtPy ESP32s3 and compiling it with log level 4 (ALL) enabled, as well as compiling and running it with log level 2 (only errors and warnings). Checked that the compiled out logs did not print and that the resultant binary was smaller.

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

New Menuconfig: CleanShot 2024-07-03 at 13 34 49

Execution with only warn and error compiled in: CleanShot 2024-07-03 at 13 33 15

Size with all logs: CleanShot 2024-07-03 at 13 34 11

Size with only error and warn logs: CleanShot 2024-07-03 at 13 31 54

That's a savings of ~31 kB, just by compiling out debug and info logs!

Types of changes

Checklist:

Software

github-actions[bot] commented 3 months ago

:white_check_mark:Static analysis result - no issues found! :white_check_mark: