log4Esp is a light-wight logging library for ESP8266.

Namespace

namespace log4Esp
class Appender
#include <Appender.h>

Appenders represent a logging destination.

Subclassed by log4Esp::RollingFileAppender, log4Esp::SerialAppender

class RollingFileAppender : public log4Esp::Appender
#include <RollingFileAppender.h>

RollingFileAppender logs data to a rolling file.

class SerialAppender : public log4Esp::Appender
#include <SerialAppender.h>

SerialAppender logs data to Serial.

Classes

class Logger

Public Functions

Logger(const char *name = "default", bool addDefaultSerialAppender = true)

Logger represents the central interface to all log operations.

Parameters

template <class T, typename... Args>
void fatal(T msg, Args... args)

Print a log entry in [fatal] mode to all associated Appenders.

Parameters
  • msg: log entry with optional format instructions and placeholders
  • args: arguments replacing placeholders

template <class T, typename... Args>
void error(T msg, Args... args)

Print a log entry in [error] mode to all associated Appenders.

Parameters
  • msg: log entry with optional format instructions and placeholders
  • args: arguments replacing placeholders

template <class T, typename... Args>
void warning(T msg, Args... args)

Print a log entry in [warning] mode to all associated Appenders.

Parameters
  • msg: log entry with optional format instructions and placeholders
  • args: arguments replacing placeholders

template <class T, typename... Args>
void verbose(T msg, Args... args)

Print a log entry in [verbose] mode to all associated Appenders.

Parameters
  • msg: log entry with optional format instructions and placeholders
  • args: arguments replacing placeholders

template <class T, typename... Args>
void trace(T msg, Args... args)

Print a log entry in [trace] mode to all associated Appenders.

Parameters
  • msg: log entry with optional format instructions and placeholders
  • args: arguments replacing placeholders

const char *getName()

Return
internal Logger name

std::vector<Appender *> &getAppender()

Return
list of associated Appenders

void addFormatterToAll(Appender::FormatterFunction formatterFunction)

Parameters
  • add: same FormatterFunction to all associated Appenders

void addFilterToAll(Appender::FilterFunction filterFunction)

Parameters
  • add: same Filter to all associated Appenders

void addLevelToAll(Appender::Level level)

Parameters
  • add: same Level to all associated Appenders

template <class T>
void print(Appender::Level level, T msg, ...)

Print a log entry to all associated Appenders.

Parameters
  • level: represents logging level of entry
  • msg: log entry with optional format instructions and placeholders
  • args: arguments replacing placeholders

class Appender

Appenders represent a logging destination.

Subclassed by log4Esp::RollingFileAppender, log4Esp::SerialAppender

Public Functions

virtual Print &getOutput() = 0

Return
output reference

Appender::FormatterFunction getFormatter()

Return
associated Formatter

void setFormatter(FormatterFunction formatterFunction)

Parameters
  • set: Formatter

std::vector<Appender::FilterFunction> &getFilter()

Return
all associated Filters

void addFilter(FilterFunction filterFunction)

Parameters
  • add: a Filter

void setLevel(Level level)

Parameters
  • set: a certain logging Level

void print(Level level, const char *msg, va_list *args)

Print a log entry.

Parameters
  • level: represents logging level of entry
  • msg: log entry with optional format instructions and placeholders
  • args: arguments replacing placeholders

Public Static Functions

Appender::FormatterFunction getDefaultFormatter()

Return
default Formatter instance

const __FlashStringHelper *toString(Level level, bool shortName = true)

Return
Level as String representation