IRSOL
C++ code implementing socket server for interacting with Baumer camera.
logging.hpp File Reference

Logging utilities and configuration for the irsol library. More...

#include "irsol/types.hpp"
#include <optional>
#include <spdlog/spdlog.h>
#include <unordered_map>

Go to the source code of this file.

Classes

struct  irsol::internal::LoggerInfo
 Metadata for a named logger instance. More...
 
class  irsol::internal::NamedLoggerRegistry
 Manages a registry of named loggers. More...
 

Namespaces

namespace  irsol
 
namespace  irsol::internal
 

Macros

#define SPDLOG_ACTIVE_LEVEL   2
 Controls the compile-time minimum logging level.
 
#define IRSOL_LOG_TRACE(...)   SPDLOG_TRACE(__VA_ARGS__)
 Logs a trace-level message using the default logger.
 
#define IRSOL_LOG_DEBUG(...)   SPDLOG_DEBUG(__VA_ARGS__)
 Logs a debug-level message using the default logger.
 
#define IRSOL_LOG_INFO(...)   SPDLOG_INFO(__VA_ARGS__)
 Logs an info-level message using the default logger.
 
#define IRSOL_LOG_WARN(...)   SPDLOG_WARN(__VA_ARGS__)
 Logs a warning-level message using the default logger.
 
#define IRSOL_LOG_ERROR(...)   SPDLOG_ERROR(__VA_ARGS__)
 Logs an error-level message using the default logger.
 
#define IRSOL_LOG_FATAL(...)   SPDLOG_CRITICAL(__VA_ARGS__)
 Logs a fatal (critical) message using the default logger.
 
#define IRSOL_NAMED_LOG_TRACE(name, ...)    irsol::internal::NamedLoggerRegistry::getLogger(name)->trace(__VA_ARGS__)
 Logs a trace-level message using a named logger.
 
#define IRSOL_NAMED_LOG_DEBUG(name, ...)    irsol::internal::NamedLoggerRegistry::getLogger(name)->debug(__VA_ARGS__)
 Logs a debug-level message using a named logger.
 
#define IRSOL_NAMED_LOG_INFO(name, ...)    irsol::internal::NamedLoggerRegistry::getLogger(name)->info(__VA_ARGS__)
 Logs an info-level message using a named logger.
 
#define IRSOL_NAMED_LOG_WARN(name, ...)    irsol::internal::NamedLoggerRegistry::getLogger(name)->warn(__VA_ARGS__)
 Logs a warning-level message using a named logger.
 
#define IRSOL_NAMED_LOG_ERROR(name, ...)    irsol::internal::NamedLoggerRegistry::getLogger(name)->error(__VA_ARGS__)
 Logs an error-level message using a named logger.
 
#define IRSOL_NAMED_LOG_FATAL(name, ...)    irsol::internal::NamedLoggerRegistry::getLogger(name)->critical(__VA_ARGS__)
 Logs a fatal (critical) message using a named logger.
 

Enumerations

enum class  irsol::LoggingFormat { irsol::LoggingFormat::CONSOLE , irsol::LoggingFormat::FILE , irsol::LoggingFormat::UNIT_TESTS }
 Enum representing supported logging output formats. More...
 

Functions

void irsol::setLoggingFormat (LoggingFormat format=LoggingFormat::FILE, std::optional< std::shared_ptr< spdlog::logger > > logger=std::nullopt)
 Sets the global logging format.
 
void irsol::setSinkLoggingFormat (LoggingFormat format, std::shared_ptr< spdlog::sinks::sink > sink)
 Sets the logging format for a specific sink.
 
void irsol::setLoggerName (const char *name)
 Sets the name of the default logger.
 
void irsol::initLogging (const char *fileSinkFilename="logs/irsol.log", std::optional< spdlog::level::level_enum > minLogLevel=std::nullopt)
 Initializes the irsol logging system.
 

Variables

const std::unordered_map< std::string, spdlog::level::level_enum > irsol::levelNameToLevelMap
 Runtime map from string names to spdlog log levels.
 

Detailed Description

Logging utilities and configuration for the irsol library.

Provides macros and functions for consistent and configurable logging using spdlog. Supports named loggers, different output formats, and compile-time level control.

This logging interface is built on top of the spdlog library.

Definition in file logging.hpp.

Macro Definition Documentation

◆ SPDLOG_ACTIVE_LEVEL

#define SPDLOG_ACTIVE_LEVEL   2

Controls the compile-time minimum logging level.

If not defined externally, this header sets it to:

  • SPDLOG_LEVEL_TRACE (0) when compiled with DEBUG mode.
  • SPDLOG_LEVEL_INFO (2) when compiled in release mode.

All logging macros that correspond to a level lower than the one defined by the SPDLOG_ACTIVE_LEVEL are disabled at compile time.

Definition at line 27 of file logging.hpp.