boost::log::attributes::basic_named_scope — A class of an attribute that holds stack of named scopes of the current thread.
// In header: <boost/log/attributes/named_scope.hpp> template<typename CharT> class basic_named_scope : public attribute { public: // types typedef CharT char_type; // Character type. typedef basic_named_scope_list< char_type > scope_stack; // Scope names stack (the attribute value type) typedef scope_stack::value_type scope_entry; // Scope entry. // member classes/structs/unions // Sentry object class to automatically push and pop scopes. struct sentry { // types typedef basic_named_scope< char_type > named_scope_type; // Attribute type. // construct/copy/destruct sentry(basic_string_literal< char_type > const &, basic_string_literal< char_type > const &, unsigned int); ~sentry(); }; // construct/copy/destruct basic_named_scope(); // public member functions shared_ptr< attribute_value > get_value(); // public static functions static void push_scope(scope_entry const &); static void pop_scope(); static scope_stack const & get_scopes(); };
The basic_named_scope attribute is essentially a hook to the thread-specific instance of scope list. This means that the attribute will generate different values if get_value is called in different threads. The attribute generates value with stored type basic_named_scope_list< CharT >
.
The attribute class can also be used to gain access to the scope stack instance, e.g. to get its copy or to push or pop a scope entry. However, it is highly not recommended to maintain scope list manually. Use BOOST_LOG_NAMED_SCOPE
or BOOST_LOG_FUNCTION
macros instead.
basic_named_scope
public member functionsshared_ptr< attribute_value > get_value();
Returns: | The actual attribute value. It shall not return NULL (exceptions shall be used to indicate errors). |
basic_named_scope
public static functionsstatic void push_scope(scope_entry const & entry);
The method pushes the scope to the back of the current thread's scope list
Throws: Nothing.
static void pop_scope();
The method pops the last pushed scope from the current thread's scope list
Throws: Nothing.
static scope_stack const & get_scopes();
Note | |
---|---|
The returned reference is only valid until the current thread ends. The scopes in the returned container may change if the execution scope is changed (i.e. either |
Returns: | The current thread's list of scopes |