4 #include "PicoStreamPrintf.h"
7 #define PICO_LOG_LEVEL Error
35 this->log_stream_ptr = &out;
36 this->log_level = level;
41 return log_stream_ptr!=
nullptr && level >= log_level;
45 virtual void error(
const char *str,
const char* str1=
nullptr,
const char* str2=
nullptr){
46 log(Error, str, str1, str2);
50 virtual void info(
const char *str,
const char* str1=
nullptr,
const char* str2=
nullptr){
51 log(Info, str, str1, str2);
55 virtual void warning(
const char *str,
const char* str1=
nullptr,
const char* str2=
nullptr){
56 log(Warning, str, str1, str2);
60 virtual void debug(
const char *str,
const char* str1=
nullptr,
const char* str2=
nullptr){
61 log(Debug, str, str1, str2);
67 if (log_stream_ptr!=
nullptr && current_level >= log_level){
68 char serial_printf_buffer[PRINTF_BUFFER_SIZE] = {0};
71 len = vsnprintf(serial_printf_buffer,PRINTF_BUFFER_SIZE, fmt, args);
72 log_stream_ptr->print(serial_printf_buffer);
80 virtual void log(
LogLevel current_level,
const char *str,
const char* str1=
nullptr,
const char* str2=
nullptr){
81 if (log_stream_ptr!=
nullptr){
82 if (current_level >= log_level){
83 log_stream_ptr->print((
char*)str);
85 log_stream_ptr->print(
" ");
86 log_stream_ptr->print(str1);
89 log_stream_ptr->print(
" ");
90 log_stream_ptr->print(str2);
92 log_stream_ptr->println();
93 log_stream_ptr->flush();
105 inline PicoLogger Logger;
A simple Logger that writes messages dependent on the log level.
Definition: PicoLogger.h:18
virtual int printf(LogLevel current_level, const char *fmt,...)
printf support
Definition: PicoLogger.h:65
LogLevel
Supported log levels. You can change the default log level with the help of the PICO_LOG_LEVEL define...
Definition: PicoLogger.h:24
virtual void log(LogLevel current_level, const char *str, const char *str1=nullptr, const char *str2=nullptr)
write an message to the log
Definition: PicoLogger.h:80
virtual bool isLogging(LogLevel level=Info)
checks if the logging is active
Definition: PicoLogger.h:40
virtual void error(const char *str, const char *str1=nullptr, const char *str2=nullptr)
logs an error
Definition: PicoLogger.h:45
virtual void info(const char *str, const char *str1=nullptr, const char *str2=nullptr)
logs an info message
Definition: PicoLogger.h:50
virtual void warning(const char *str, const char *str1=nullptr, const char *str2=nullptr)
logs an warning
Definition: PicoLogger.h:55
virtual void debug(const char *str, const char *str1=nullptr, const char *str2=nullptr)
writes an debug message
Definition: PicoLogger.h:60
virtual void begin(Stream &out, LogLevel level=PICO_LOG_LEVEL)
activate the logging
Definition: PicoLogger.h:34
Pico Arduino Framework.
Definition: Arduino.cpp:26