C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::logger Class Referenceabstract

Centrally logs events from all actors in an actor system. More...

#include <logger.hpp>

Classes

class  entrypoint
 Provides an API entry point for sending a log event to the current logger. More...
 
class  line_builder
 Utility class for building user-defined log messages with CAF_ARG. More...
 
class  trace_exit_guard
 Helper class to print exit trace messages on scope exit. More...
 

Public Member Functions

virtual bool accepts (unsigned level, std::string_view component_name)=0
 Returns whether the logger is configured to accept input for given component and log level.
 
virtual void ref_logger () const noexcept=0
 Increases the reference count of the logger.
 
virtual void deref_logger () const noexcept=0
 Decreases the reference count of the logger and destroys the object if necessary.
 

Static Public Member Functions

template<class... Ts>
static void log (unsigned level, std::string_view component, format_string_with_location fmt_str, Ts &&... args)
 Logs a message.
 
template<class... Ts>
static entrypoint log (unsigned level, std::string_view component, detail::source_location loc=detail::source_location::current())
 Starts a new log event.
 
template<class... Ts>
static trace_exit_guard trace (std::string_view component, format_string_with_location fmt_str, Ts &&... args)
 Logs a message with trace severity.
 
static actor_id thread_local_aid ()
 Returns the ID of the actor currently associated to the calling thread.
 
static actor_id thread_local_aid (actor_id aid) noexcept
 Associates an actor ID to the calling thread and returns the last value.
 
static intrusive_ptr< loggermake (actor_system &sys)
 Creates a new logger instance.
 
static void set_current_actor_system ()
 
static loggercurrent_logger ()
 Returns the logger for the current thread or nullptr if none is registered.
 
static void current_logger (actor_system *sys)
 Sets the logger for the current thread.
 
static void current_logger (logger *ptr)
 Sets the logger for the current thread.
 
static void current_logger (std::nullptr_t)
 Sets the logger for the current thread.
 

Friends

class actor_system
 
class detail::actor_system_access
 
class trace_exit_guard
 
class log::event_sender
 
void intrusive_ptr_add_ref (const logger *ptr) noexcept
 
void intrusive_ptr_release (const logger *ptr) noexcept
 

Detailed Description

Centrally logs events from all actors in an actor system.

To enable logging in your application, you need to define CAF_LOG_LEVEL. Per default, the logger generates log4j compatible output.

Member Function Documentation

◆ log() [1/2]

template<class... Ts>
static entrypoint caf::logger::log ( unsigned level,
std::string_view component,
detail::source_location loc = detail::source_location::current() )
static

Starts a new log event.

Parameters
componentName of the component logging the message.

◆ log() [2/2]

template<class... Ts>
static void caf::logger::log ( unsigned level,
std::string_view component,
format_string_with_location fmt_str,
Ts &&... args )
static

Logs a message.

Parameters
levelSeverity of the message.
componentName of the component logging the message.
fmt_strThe format string (with source location) for the message.
argsArguments for the format string.

◆ trace()

template<class... Ts>
static trace_exit_guard caf::logger::trace ( std::string_view component,
format_string_with_location fmt_str,
Ts &&... args )
staticnodiscard

Logs a message with trace severity.

Parameters
componentName of the component logging the message.
fmt_strThe format string (with source location) for the message.
argsArguments for the format string.

The documentation for this class was generated from the following files: