Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:39:27

0001 /*
0002  *          Copyright Andrey Semashev 2007 - 2015.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   common_attributes.hpp
0009  * \author Andrey Semashev
0010  * \date   16.05.2008
0011  *
0012  * The header contains implementation of convenience functions for registering commonly used attributes.
0013  */
0014 
0015 #ifndef BOOST_LOG_UTILITY_SETUP_COMMON_ATTRIBUTES_HPP_INCLUDED_
0016 #define BOOST_LOG_UTILITY_SETUP_COMMON_ATTRIBUTES_HPP_INCLUDED_
0017 
0018 #include <iostream>
0019 #include <boost/log/detail/config.hpp>
0020 #include <boost/log/core/core.hpp>
0021 #include <boost/log/attributes/clock.hpp>
0022 #include <boost/log/attributes/counter.hpp>
0023 #include <boost/log/attributes/current_process_id.hpp>
0024 #if !defined(BOOST_LOG_NO_THREADS)
0025 #include <boost/log/attributes/current_thread_id.hpp>
0026 #endif
0027 #include <boost/log/detail/default_attribute_names.hpp>
0028 #include <boost/log/detail/header.hpp>
0029 
0030 #ifdef BOOST_HAS_PRAGMA_ONCE
0031 #pragma once
0032 #endif
0033 
0034 namespace boost {
0035 
0036 BOOST_LOG_OPEN_NAMESPACE
0037 
0038 /*!
0039  * \brief Simple attribute initialization routine
0040  *
0041  * The function adds commonly used attributes to the logging system. Specifically, the following
0042  * attributes are registered globally:
0043  *
0044  * \li LineID - logging records counter with value type <tt>unsigned int</tt>
0045  * \li TimeStamp - local time generator with value type <tt>boost::posix_time::ptime</tt>
0046  * \li ProcessID - current process identifier with value type
0047  *     <tt>attributes::current_process_id::value_type</tt>
0048  * \li ThreadID - in multithreaded builds, current thread identifier with
0049  *     value type <tt>attributes::current_thread_id::value_type</tt>
0050  */
0051 inline void add_common_attributes()
0052 {
0053     shared_ptr< core > pCore = core::get();
0054     pCore->add_global_attribute(
0055         aux::default_attribute_names::line_id(),
0056         attributes::counter< unsigned int >(1));
0057     pCore->add_global_attribute(
0058         aux::default_attribute_names::timestamp(),
0059         attributes::local_clock());
0060     pCore->add_global_attribute(
0061         aux::default_attribute_names::process_id(),
0062         attributes::current_process_id());
0063 #if !defined(BOOST_LOG_NO_THREADS)
0064     pCore->add_global_attribute(
0065         aux::default_attribute_names::thread_id(),
0066         attributes::current_thread_id());
0067 #endif
0068 }
0069 
0070 BOOST_LOG_CLOSE_NAMESPACE // namespace log
0071 
0072 } // namespace boost
0073 
0074 #include <boost/log/detail/footer.hpp>
0075 
0076 #endif // BOOST_LOG_UTILITY_SETUP_COMMON_ATTRIBUTES_HPP_INCLUDED_