2
* Copyright Andrey Semashev 2007 - 2013.
3
* Distributed under the Boost Software License, Version 1.0.
4
* (See accompanying file LICENSE_1_0.txt or copy at
5
* http://www.boost.org/LICENSE_1_0.txt)
8
* \file common_attributes.hpp
9
* \author Andrey Semashev
12
* The header contains implementation of convenience functions for registering commonly used attributes.
15
#ifndef BOOST_LOG_UTILITY_SETUP_COMMON_ATTRIBUTES_HPP_INCLUDED_
16
#define BOOST_LOG_UTILITY_SETUP_COMMON_ATTRIBUTES_HPP_INCLUDED_
19
#include <boost/log/detail/config.hpp>
20
#include <boost/log/core/core.hpp>
21
#include <boost/log/attributes/clock.hpp>
22
#include <boost/log/attributes/counter.hpp>
23
#include <boost/log/attributes/current_process_id.hpp>
24
#if !defined(BOOST_LOG_NO_THREADS)
25
#include <boost/log/attributes/current_thread_id.hpp>
27
#include <boost/log/detail/default_attribute_names.hpp>
28
#include <boost/log/detail/header.hpp>
30
#ifdef BOOST_LOG_HAS_PRAGMA_ONCE
36
BOOST_LOG_OPEN_NAMESPACE
39
* \brief Simple attribute initialization routine
41
* The function adds commonly used attributes to the logging system. Specifically, the following
42
* attributes are registered globally:
44
* \li LineID - logging records counter with value type <tt>unsigned int</tt>
45
* \li TimeStamp - local time generator with value type <tt>boost::posix_time::ptime</tt>
46
* \li ProcessID - current process identifier with value type
47
* <tt>attributes::current_process_id::value_type</tt>
48
* \li ThreadID - in multithreaded builds, current thread identifier with
49
* value type <tt>attributes::current_thread_id::value_type</tt>
51
inline void add_common_attributes()
53
shared_ptr< core > pCore = core::get();
54
pCore->add_global_attribute(
55
aux::default_attribute_names::line_id(),
56
attributes::counter< unsigned int >(1));
57
pCore->add_global_attribute(
58
aux::default_attribute_names::timestamp(),
59
attributes::local_clock());
60
pCore->add_global_attribute(
61
aux::default_attribute_names::process_id(),
62
attributes::current_process_id());
63
#if !defined(BOOST_LOG_NO_THREADS)
64
pCore->add_global_attribute(
65
aux::default_attribute_names::thread_id(),
66
attributes::current_thread_id());
70
BOOST_LOG_CLOSE_NAMESPACE // namespace log
74
#include <boost/log/detail/footer.hpp>
76
#endif // BOOST_LOG_UTILITY_SETUP_COMMON_ATTRIBUTES_HPP_INCLUDED_