Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template basic_logger

boost::log::sources::basic_logger — Basic logger class.

Synopsis

// In header: <boost/log/sources/basic_logger.hpp>

template<typename CharT, typename FinalT, typename ThreadingModelT> 
class basic_logger : public ThreadingModelT {
public:
  // types
  typedef CharT                      char_type;                   // Character type. 
  typedef FinalT                     final_type;                  // Final logger type. 
  typedef ThreadingModelT            threading_model;             // Threading model type. 
  typedef unspecified                swap_lock;                   // Lock requirement for the swap_unlocked method. 
  typedef unspecified                add_attribute_lock;          // Lock requirement for the add_attribute_unlocked method. 
  typedef unspecified                remove_attribute_lock;       // Lock requirement for the remove_attribute_unlocked method. 
  typedef unspecified                remove_all_attributes_lock;  // Lock requirement for the remove_all_attributes_unlocked method. 
  typedef unspecified                get_attributes_lock;         // Lock requirement for the get_attributes method. 
  typedef unspecified                open_record_lock;            // Lock requirement for the open_record_unlocked method. 
  typedef unspecified                set_attributes_lock;         // Lock requirement for the set_attributes method. 
  typedef no_lock< threading_model > push_record_lock;            // Lock requirement for the push_record_unlocked method. 

  // construct/copy/destruct
  basic_logger();
  basic_logger(basic_logger const &);
  basic_logger(basic_logger &&);
  template<typename ArgsT> explicit basic_logger(ArgsT const &);
  basic_logger & operator=(basic_logger const &) = delete;

  // protected member functions
  core_ptr const  & core() const;
  attribute_set & attributes();
  attribute_set const  & attributes() const;
  threading_model & get_threading_model();
  threading_model const  & get_threading_model() const;
  final_type * final_this();
  final_type const  * final_this() const;
  void swap_unlocked(basic_logger &);
  std::pair< attribute_set::iterator, bool > 
  add_attribute_unlocked(attribute_name const &, attribute const &);
  void remove_attribute_unlocked(attribute_set::iterator);
  void remove_all_attributes_unlocked();
  record open_record_unlocked();
  template<typename ArgsT> record open_record_unlocked(ArgsT const &);
  void push_record_unlocked(record &&);
  attribute_set get_attributes_unlocked() const;
  void set_attributes_unlocked(attribute_set const &);
};

Description

The basic_logger class template serves as a base class for all loggers provided by the library. It can also be used as a base for user-defined loggers. The template parameters are:

  • CharT - logging character type

  • FinalT - final type of the logger that eventually derives from the basic_logger. There may be other classes in the hierarchy between the final class and basic_logger.

  • ThreadingModelT - threading model policy. Must provide methods of the Boost.Thread locking concept used in basic_logger class and all its derivatives in the hierarchy up to the FinalT class. The basic_logger class itself requires methods of the SharedLockable concept. The threading model policy must also be default and copy-constructible and support member function swap. There are currently two policies provided: single_thread_model and multi_thread_model.

The logger implements fundamental facilities of loggers, such as storing source-specific attribute set and formatting log record messages. The basic logger interacts with the logging core in order to apply filtering and pass records to sinks.

basic_logger public construct/copy/destruct

  1. basic_logger();

    Constructor. Initializes internal data structures of the basic logger class, acquires reference to the logging core.

  2. basic_logger(basic_logger const & that);

    Copy constructor. Copies all attributes from the source logger.

    [Note] Note

    Not thread-safe. The source logger must be locked in the final class before copying.

    Parameters:

    that

    Source logger

  3. basic_logger(basic_logger && that);

    Move constructor. Moves all attributes from the source logger.

    [Note] Note

    Not thread-safe. The source logger must be locked in the final class before copying.

    Parameters:

    that

    Source logger

  4. template<typename ArgsT> explicit basic_logger(ArgsT const &);

    Constructor with named arguments. The constructor ignores all arguments. The result of construction is equivalent to default construction.

  5. basic_logger & operator=(basic_logger const &) = delete;
    Assignment is closed (should be implemented through copy and swap in the final class)

basic_logger protected member functions

  1. core_ptr const  & core() const;

    An accessor to the logging system pointer

  2. attribute_set & attributes();

    An accessor to the logger attributes

  3. attribute_set const  & attributes() const;

    An accessor to the logger attributes

  4. threading_model & get_threading_model();

    An accessor to the threading model base

  5. threading_model const  & get_threading_model() const;

    An accessor to the threading model base

  6. final_type * final_this();

    An accessor to the final logger

  7. final_type const  * final_this() const;

    An accessor to the final logger

  8. void swap_unlocked(basic_logger & that);

    Unlocked swap

  9. std::pair< attribute_set::iterator, bool > 
    add_attribute_unlocked(attribute_name const & name, attribute const & attr);

    Unlocked add_attribute

  10. void remove_attribute_unlocked(attribute_set::iterator it);

    Unlocked remove_attribute

  11. void remove_all_attributes_unlocked();

    Unlocked remove_all_attributes

  12. record open_record_unlocked();

    Unlocked open_record

  13. template<typename ArgsT> record open_record_unlocked(ArgsT const &);

    Unlocked open_record

  14. void push_record_unlocked(record && rec);

    Unlocked push_record

  15. attribute_set get_attributes_unlocked() const;

    Unlocked get_attributes

  16. void set_attributes_unlocked(attribute_set const & attrs);

    Unlocked set_attributes


PrevUpHomeNext