Common System 0.2.0
Common interfaces and patterns for system integration
Loading...
Searching...
No Matches
log_functions.h File Reference

Unified logging functions with source_location support. More...

#include "../interfaces/global_logger_registry.h"
#include "../utils/source_location.h"
#include <memory>
#include <string>
#include <string_view>
Include dependency graph for log_functions.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  kcenon
 
namespace  kcenon::common
 Core interfaces.
 
namespace  kcenon::common::logging
 

Functions

VoidResult kcenon::common::logging::log (interfaces::log_level level, std::string_view message, const source_location &loc=source_location::current())
 Log a message with the specified level and source location.
 
VoidResult kcenon::common::logging::log (interfaces::log_level level, std::string_view message, const std::shared_ptr< interfaces::ILogger > &logger, const source_location &loc=source_location::current())
 Log a message to a specific logger with source location.
 
VoidResult kcenon::common::logging::log (interfaces::log_level level, std::string_view message, const std::string &logger_name, const source_location &loc=source_location::current())
 Log a message to a named logger with source location.
 
VoidResult kcenon::common::logging::log_trace (std::string_view message, const source_location &loc=source_location::current())
 Log a trace-level message.
 
VoidResult kcenon::common::logging::log_debug (std::string_view message, const source_location &loc=source_location::current())
 Log a debug-level message.
 
VoidResult kcenon::common::logging::log_info (std::string_view message, const source_location &loc=source_location::current())
 Log an info-level message.
 
VoidResult kcenon::common::logging::log_warning (std::string_view message, const source_location &loc=source_location::current())
 Log a warning-level message.
 
VoidResult kcenon::common::logging::log_error (std::string_view message, const source_location &loc=source_location::current())
 Log an error-level message.
 
VoidResult kcenon::common::logging::log_critical (std::string_view message, const source_location &loc=source_location::current())
 Log a critical-level message.
 
VoidResult kcenon::common::logging::log_trace_to (const std::string &logger_name, std::string_view message, const source_location &loc=source_location::current())
 Log a trace-level message to a named logger.
 
VoidResult kcenon::common::logging::log_debug_to (const std::string &logger_name, std::string_view message, const source_location &loc=source_location::current())
 Log a debug-level message to a named logger.
 
VoidResult kcenon::common::logging::log_info_to (const std::string &logger_name, std::string_view message, const source_location &loc=source_location::current())
 Log an info-level message to a named logger.
 
VoidResult kcenon::common::logging::log_warning_to (const std::string &logger_name, std::string_view message, const source_location &loc=source_location::current())
 Log a warning-level message to a named logger.
 
VoidResult kcenon::common::logging::log_error_to (const std::string &logger_name, std::string_view message, const source_location &loc=source_location::current())
 Log an error-level message to a named logger.
 
VoidResult kcenon::common::logging::log_critical_to (const std::string &logger_name, std::string_view message, const source_location &loc=source_location::current())
 Log a critical-level message to a named logger.
 
bool kcenon::common::logging::is_enabled (interfaces::log_level level)
 Check if a log level is enabled for the default logger.
 
bool kcenon::common::logging::is_enabled (interfaces::log_level level, const std::string &logger_name)
 Check if a log level is enabled for a named logger.
 
VoidResult kcenon::common::logging::flush ()
 Flush all buffered log messages for the default logger.
 
VoidResult kcenon::common::logging::flush (const std::string &logger_name)
 Flush all buffered log messages for a named logger.
 

Detailed Description

Unified logging functions with source_location support.

This header provides inline logging functions that automatically capture source location information (file, line, function) at the call site. These functions integrate with GlobalLoggerRegistry to provide a consistent logging interface across all subsystems.

Thread Safety:

  • All logging functions are thread-safe.
  • Source location capture happens at compile-time.
  • Logger retrieval uses GlobalLoggerRegistry which is thread-safe.

Usage:

// Basic logging
kcenon::common::logging::log_info("Application started");
// Different log levels
kcenon::common::logging::log_trace("Detailed trace info");
// Using named logger
auto network_logger = get_logger("network");
kcenon::common::logging::log(log_level::info, "Connected", network_logger);
VoidResult log_warning(std::string_view message, const source_location &loc=source_location::current())
Log a warning-level message.
VoidResult log_debug(std::string_view message, const source_location &loc=source_location::current())
Log a debug-level message.
VoidResult log_critical(std::string_view message, const source_location &loc=source_location::current())
Log a critical-level message.
VoidResult log_error(std::string_view message, const source_location &loc=source_location::current())
Log an error-level message.
VoidResult log(interfaces::log_level level, std::string_view message, const source_location &loc=source_location::current())
Log a message with the specified level and source location.
VoidResult log_trace(std::string_view message, const source_location &loc=source_location::current())
Log a trace-level message.
VoidResult log_info(std::string_view message, const source_location &loc=source_location::current())
Log an info-level message.
See also
Issue #175 for implementation requirements.
global_logger_registry.h for logger management.
source_location.h for source location support.

Definition in file log_functions.h.