My Project
Classes | Enumerations | Functions | Variables
uuid::log Namespace Reference

Logging framework. More...

Classes

class  Handler
 Logger handler used to process log messages. More...
 
class  Logger
 Logger instance used to make log messages. More...
 
struct  Message
 Log message text with timestamp and logger attributes. More...
 
class  PrintHandler
 Basic log handler for writing messages to any object supporting the Print interface. More...
 

Enumerations

enum  Level : int8_t {
  OFF = -1, EMERG = 0, ALERT, CRIT,
  ERR, WARNING, NOTICE, INFO,
  DEBUG, TRACE, ALL
}
 Severity level of log messages. More...
 
enum  Facility : uint8_t {
  KERN = 0, USER, MAIL, DAEMON,
  AUTH, SYSLOG, LPR, NEWS,
  UUCP, CRON, AUTHPRIV, FTP,
  NTP, SECURITY, CONSOLE, CRON2,
  LOCAL0, LOCAL1, LOCAL2, LOCAL3,
  LOCAL4, LOCAL5, LOCAL6, LOCAL7
}
 Facility type of the process logging a message. More...
 

Functions

char format_level_char (Level level)
 Format a log level as a single character. More...
 
const __FlashStringHelper * format_level_lowercase (Level level)
 Format a log level as a lowercase string. More...
 
const __FlashStringHelper * format_level_uppercase (Level level)
 Format a log level as an uppercase string. More...
 
std::string format_timestamp_ms (uint64_t timestamp_ms, unsigned int days_width=1)
 Format a system uptime timestamp as a string. More...
 
std::vector< Levellevels ()
 Get all log levels. More...
 
std::vector< std::string > levels_lowercase ()
 Get all log levels as lowercase strings. More...
 
std::vector< std::string > levels_uppercase ()
 Get all log levels as uppercase strings. More...
 
bool parse_level_lowercase (const std::string &name, Level &level)
 Parse a lowercase string to a log level. More...
 
bool parse_level_uppercase (const std::string &name, Level &level)
 Parse an uppercase string to a log level. More...
 

Variables

static constexpr bool thread_safe = false
 Thread-safe status of the library. More...
 

Detailed Description

Logging framework.

Provides a framework for handling log messages. This library is for single threaded applications and cannot be used from an interrupt context.

Enumeration Type Documentation

◆ Facility

enum uuid::log::Facility : uint8_t

Facility type of the process logging a message.

Since
1.0.0
Enumerator
KERN 

Kernel messages.

Since
1.0.0
USER 

User-level messages.

Since
1.0.0
MAIL 

Mail system.

Since
1.0.0
DAEMON 

System daemons.

Since
1.0.0
AUTH 

Security/authentication messages.

Since
1.0.0
SYSLOG 

Messages generated internally by logger.

Since
1.0.0
LPR 

Line printer subsystem.

Since
1.0.0
NEWS 

Network news subsystem.

Since
1.0.0
UUCP 

UUCP subsystem.

Since
1.0.0
CRON 

Clock daemon.

Since
1.0.0
AUTHPRIV 

Security/authentication messages (private).

Since
1.0.0
FTP 

FTP daemon.

Since
1.0.0
NTP 

NTP subsystem.

Since
1.0.0
SECURITY 

Log audit.

Since
1.0.0
CONSOLE 

Log alert.

Since
1.0.0
CRON2 

Scheduling daemon.

Since
1.0.0
LOCAL0 

Locally used facility 0.

Since
1.0.0
LOCAL1 

Locally used facility 1.

Since
1.0.0
LOCAL2 

Locally used facility 2.

Since
1.0.0
LOCAL3 

Locally used facility 3.

Since
1.0.0
LOCAL4 

Locally used facility 4.

Since
1.0.0
LOCAL5 

Locally used facility 5.

Since
1.0.0
LOCAL6 

Locally used facility 6.

Since
1.0.0
LOCAL7 

Locally used facility 7.

Since
1.0.0

Definition at line 103 of file log.h.

◆ Level

enum uuid::log::Level : int8_t

Severity level of log messages.

Since
1.0.0
Enumerator
OFF 

Meta level representing no log messages.

Since
1.0.0
EMERG 

System is unusable.

Since
1.0.0
ALERT 

Action must be taken immediately.

Since
1.0.0
CRIT 

Critical conditions.

Since
1.0.0
ERR 

Error conditions.

Since
1.0.0
WARNING 

Warning conditions.

Since
1.0.0
NOTICE 

Normal but significant conditions.

Since
1.0.0
INFO 

Informational messages.

Since
1.0.0
DEBUG 

Debug-level messages.

Since
1.0.0
TRACE 

Trace messages.

Since
1.0.0
ALL 

Meta level representing all log messages.

Since
1.0.0

Definition at line 84 of file log.h.

Function Documentation

◆ format_level_char()

char uuid::log::format_level_char ( Level  level)

Format a log level as a single character.

Level::EMERG is represented as 'P' because it conflicts with Level::ERR and it used to be the "panic" level.

Parameters
[in]levelLog level.
Returns
Single character uppercase representation of the log level.
Since
1.0.0

Definition at line 25 of file format_level_char.cpp.

◆ format_level_lowercase()

const __FlashStringHelper * uuid::log::format_level_lowercase ( Level  level)

Format a log level as a lowercase string.

Parameters
[in]levelLog level.
Returns
Lowercase name of the log level (flash string).
Since
1.0.0

Definition at line 61 of file format_level_lowercase.cpp.

◆ format_level_uppercase()

const __FlashStringHelper * uuid::log::format_level_uppercase ( Level  level)

Format a log level as an uppercase string.

Parameters
[in]levelLog level.
Returns
Uppercase name of the log level (flash string).
Since
1.0.0

Definition at line 61 of file format_level_uppercase.cpp.

◆ format_timestamp_ms()

std::string uuid::log::format_timestamp_ms ( uint64_t  timestamp_ms,
unsigned int  days_width = 1 
)

Format a system uptime timestamp as a string.

Using the format "d+HH:mm:ss.SSS" with leading zeros for the days.

Parameters
[in]timestamp_msSystem uptime in milliseconds, see uuid::get_uptime_ms().
[in]days_widthLeading zeros for the days part of the output.
Returns
String with the formatted system uptime.
Since
1.0.0

Definition at line 31 of file format_timestamp_ms.cpp.

◆ levels()

std::vector< Level > uuid::log::levels ( )

Get all log levels.

Returns
A list of all log levels in priority order from uuid::log::Level::OFF to uuid::log::Level::ALL.
Since
2.1.0

Definition at line 27 of file levels.cpp.

◆ levels_lowercase()

std::vector< std::string > uuid::log::levels_lowercase ( )

Get all log levels as lowercase strings.

Returns
A list of all log levels in priority order from uuid::log::Level::OFF to uuid::log::Level::ALL as lowercase strings.
Since
2.1.0

Definition at line 29 of file levels_lowercase.cpp.

◆ levels_uppercase()

std::vector< std::string > uuid::log::levels_uppercase ( )

Get all log levels as uppercase strings.

Returns
A list of all log levels in priority order from uuid::log::Level::OFF to uuid::log::Level::ALL as uppercase strings.
Since
2.1.0

Definition at line 29 of file levels_uppercase.cpp.

◆ parse_level_lowercase()

bool uuid::log::parse_level_lowercase ( const std::string &  name,
Level level 
)

Parse a lowercase string to a log level.

Parameters
[in]nameLowercase name of the log level.
[out]levelLog level.
Returns
True if the named level is valid, otherwise false.
Since
2.1.0

Definition at line 29 of file parse_level_lowercase.cpp.

◆ parse_level_uppercase()

bool uuid::log::parse_level_uppercase ( const std::string &  name,
Level level 
)

Parse an uppercase string to a log level.

Parameters
[in]nameUppercase name of the log level.
[out]levelLog level.
Returns
True if the named level is valid, otherwise false.
Since
2.1.0

Definition at line 29 of file parse_level_uppercase.cpp.

Variable Documentation

◆ thread_safe

constexpr bool uuid::log::thread_safe = false
staticconstexpr

Thread-safe status of the library.

Since
2.3.0

Definition at line 76 of file log.h.