Logger
mach::Logger
Description
Section titled “Description”Provides structured logging for Mach applications.
Headers
Section titled “Headers”Primary header:
#include <mach/Logger.hpp>Convenience header:
#include <mach/mach.hpp>Syntax
Section titled “Syntax”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;};Member Functions
Section titled “Member Functions”| Name | Description |
|---|---|
debug |
Logs a debug message. |
info |
Logs an informational message. |
warning |
Logs a warning message. |
error |
Logs an error message. |
Thread Safety
Section titled “Thread Safety”All logging operations are thread-safe and may be called concurrently from multiple threads.
Remarks
Section titled “Remarks”- 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.
Example
Section titled “Example”logger.info("User '{}' signed in.", username);logger.debug("Processed {} requests.", requestCount);logger.error("Unexpected error: {}", error.what());See Also
Section titled “See Also”| 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. |