Skip to content
Download

Logger

mach::Logger

Provides structured logging for Mach applications.

Primary header:

#include <mach/Logger.hpp>

Convenience header:

#include <mach/mach.hpp>
class Logger {
public:
~Logger();
Logger(Logger&&) noexcept;
Logger(const Logger&) = delete;
Logger& operator=(const Logger&) = delete;
template <typename... Args>
void debug(fmt::format_string<Args...> format, Args&&... args) const;
template <typename... Args>
void info(fmt::format_string<Args...> format, Args&&... args) const;
template <typename... Args>
void warning(fmt::format_string<Args...> format, Args&&... args) const;
template <typename... Args>
void error(fmt::format_string<Args...> format, Args&&... args) const;
};
Name Description
debug Logs a debug message.
info Logs an informational message.
warning Logs a warning message.
error Logs an error message.

All logging operations are thread-safe and may be called concurrently from multiple threads.

  • Logger instances are managed by Mach and are not normally constructed directly by application code.
  • The logger is configured through AppBuilder::configureLogging() before the application is built.
  • Controllers, middleware, and services should obtain a logger through dependency injection rather than constructing one directly.
logger.info("User '{}' signed in.", username);
logger.debug("Processed {} requests.", requestCount);
logger.error("Unexpected error: {}", error.what());
Name Description
LoggerOptions Configures the built-in Mach logger.
LogLevel Represents the severity of a log message.
spdlog The logging library currently used by Mach.
fmt documentation Learn more about the format string syntax supported by the logger.