Basic timestamped logger with optional SD file logging. More...
#include <Logger.h>
Collaboration diagram for Logger:Static Public Member Functions | |
| static void | info (const char *msg) |
| Log an informational message. | |
| static void | warn (const char *msg) |
| Log a warning message. | |
| static void | error (const char *msg) |
| Log an error message. | |
| static void | setMinLogLevel (LogLevel level) |
| Set the minimum log level (filters lower levels). | |
| static void | enableFileLogging (const std::string &path) |
| Enable writing logs to SD card via a storage manager. | |
| static bool | forEachLine (const std::function< void(const char *line)> &handler) |
| Streams each line of the log file to the provided handler. | |
Static Private Member Functions | |
| static void | log (LogLevel level, const char *msg) |
| static void | getTimeString (char *buffer, size_t len) |
| static const char * | levelToString (LogLevel level) |
Static Private Attributes | |
| static LogLevel | minLevel = LOG_INFO |
| static std::string | logPath = "" |
| static bool | logToFile = false |
This logger is designed for embedded use, providing filtered logging based on severity and timestamp, and supporting optional output to SD.
|
static |
Enable writing logs to SD card via a storage manager.
| path | Path to the log file on SD card (e.g. "/log/system.log"). |
| path | Path to the log file on SD card (e.g. "/log/system.log"). |
Definition at line 47 of file Logger.cpp.
|
static |
Log an error message.
| msg | The message to log. |
| msg | The message to log. |
Definition at line 35 of file Logger.cpp.
References log(), and LOG_ERROR.
Here is the call graph for this function:
|
static |
| handler | Function to call with each line (null-terminated C-string). |
Definition at line 102 of file Logger.cpp.
References AppContext::getTypeKey(), and logPath.
Here is the call graph for this function:
|
staticprivate |
Definition at line 79 of file Logger.cpp.
References PicoTime::now().
Referenced by log().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Log an informational message.
| msg | The message to log. |
| msg | The message to log. |
Definition at line 23 of file Logger.cpp.
References log(), and LOG_INFO.
Here is the call graph for this function:
|
staticprivate |
|
staticprivate |
Definition at line 54 of file Logger.cpp.
References getTimeString(), AppContext::getTypeKey(), levelToString(), logPath, logToFile, and minLevel.
Referenced by error(), info(), and warn().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Set the minimum log level (filters lower levels).
| level | Messages below this level will be suppressed. |
| level | Messages below this level will be suppressed. |
Definition at line 41 of file Logger.cpp.
References minLevel.
|
static |
|
inlinestaticprivate |
Definition at line 96 of file Logger.h.
Referenced by enableFileLogging(), forEachLine(), and log().
|
inlinestaticprivate |
Definition at line 97 of file Logger.h.
Referenced by enableFileLogging(), and log().
Definition at line 91 of file Logger.h.
Referenced by log(), and setMinLogLevel().