core-avr-logging

Log

namespace Log

Functions

void setFormatter(LogFormatter *formatter)

Sets the formatter for logs.

Parameters
  • formatter: The formatter.

void addTarget(LogTarget *target)

Adds a target to receive logs.

Parameters
  • target: The target.

void removeTarget(LogTarget *target)

Removes a target from receiving logs.

Parameters
  • target: The target.

void log(const char *level, const char *category, const char *message)

Log!

Parameters
  • level: The level of the log.
  • category: The category of the log.
  • message: The message to log.

Logger *logger(const char *category)

Retrieves a logger for a category. If a logger already exists, it returns that logger.

Return
A logger.
Parameters
  • category: The category. Can be anything.

Logger

class Logger

Logger instance.

Public Functions

Logger(const char *category)

New logger of a specific category.

Parameters
  • category: The category to prefix logs with.

void debug(const char *message)

Logs at a debug level.

Parameters
  • message: The message to log.

void info(const char *message)

Logs at an info level.

Parameters
  • message: The message to log.

void warn(const char *message)

Logs at a warn level.

Parameters
  • message: The message to log.

void error(const char *message)

Logs at an error level.

Parameters
  • message: The message to log.

LogFormatter

class LogFormatter

Formats logs.

Subclassed by DefaultFormatter, DummyFormatter

Public Functions

~LogFormatter() = 0

Destructor.

virtual const char *format(const char *level, const char *category, const char *message) = 0

Formats a log.

Return
The formatted log.
Parameters
  • level: The level of the log.
  • category: The category of the log.
  • message: The message.

LogTarget

class LogTarget

Pure virtual base class that describes the LogTarget interface.

Subclassed by ConsoleLogTarget, DummyLogTarget, FunctionPointerLogTarget, SerialLogTarget

Public Functions

~LogTarget() = 0

Destructor.

Default destructor.

virtual void log(const char *message) = 0

Logs a message.

Parameters
  • message: The message to log.

LogTarget Implementations

class SerialLogTarget

Forwards logs to Arduino Serial interface.

Inherits from LogTarget

class FunctionPointerLogTarget

Forwards logs to a function pointer.

Inherits from LogTarget

class ConsoleLogTarget

Forwards logs to stdout.

Inherits from LogTarget