C++ Actor Framework 0.19
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
caf::logger Class Referenceabstract

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

#include <logger.hpp>


struct  event
 Encapsulates a single logging event. More...
class  line_builder
 Utility class for building user-defined log messages with CAF_ARG. More...

Public Types

enum  field_type {
  invalid_field ,
  category_field ,
  class_name_field ,
  date_field ,
  file_field ,
  line_field ,
  message_field ,
  method_field ,
  newline_field ,
  priority_field ,
  runtime_field ,
  thread_field ,
  actor_field ,
  percent_sign_field ,

Public Member Functions

virtual void log (event &&x)=0
 Writes an entry to the event-queue of the logger.
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.
virtual void init (const actor_system_config &cfg)=0
 Allows the logger to read its configuration from the actor system config.
virtual void start ()=0
 Starts any background threads needed by the logger.
virtual void stop ()=0
 Stops all background threads of the logger.

Static Public Member Functions

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)
 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 render_fun_prefix (std::ostream &out, const event &x)
 Renders the prefix (namespace and class) of a fully qualified function.
static std::string_view skip_path (std::string_view filename)
 Skips path in filename.
static void set_current_actor_system (actor_system *)
 Stores the actor system for the current thread.
static loggercurrent_logger ()
 Returns the logger for the current thread or nullptr if none is registered.


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()

virtual void caf::logger::log ( event &&  x)
pure virtual

Writes an entry to the event-queue of the logger.


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