Chris@16
|
1 /*
|
Chris@101
|
2 * Copyright Andrey Semashev 2007 - 2015.
|
Chris@16
|
3 * Distributed under the Boost Software License, Version 1.0.
|
Chris@16
|
4 * (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 * http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 */
|
Chris@16
|
7 /*!
|
Chris@16
|
8 * \file current_process_name.hpp
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 29.07.2012
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains implementation of a current process name attribute
|
Chris@16
|
13 */
|
Chris@16
|
14
|
Chris@16
|
15 #ifndef BOOST_LOG_ATTRIBUTES_CURRENT_PROCESS_NAME_HPP_INCLUDED_
|
Chris@16
|
16 #define BOOST_LOG_ATTRIBUTES_CURRENT_PROCESS_NAME_HPP_INCLUDED_
|
Chris@16
|
17
|
Chris@16
|
18 #include <string>
|
Chris@16
|
19 #include <boost/log/detail/config.hpp>
|
Chris@16
|
20 #include <boost/log/attributes/constant.hpp>
|
Chris@16
|
21 #include <boost/log/attributes/attribute_cast.hpp>
|
Chris@16
|
22 #include <boost/log/detail/header.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
25 #pragma once
|
Chris@16
|
26 #endif
|
Chris@16
|
27
|
Chris@16
|
28 namespace boost {
|
Chris@16
|
29
|
Chris@16
|
30 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
31
|
Chris@16
|
32 namespace aux {
|
Chris@16
|
33
|
Chris@16
|
34 //! The function returns the current process name
|
Chris@16
|
35 BOOST_LOG_API std::string get_process_name();
|
Chris@16
|
36
|
Chris@16
|
37 } // namespace aux
|
Chris@16
|
38
|
Chris@16
|
39 namespace attributes {
|
Chris@16
|
40
|
Chris@16
|
41 /*!
|
Chris@16
|
42 * \brief A class of an attribute that holds the current process name
|
Chris@16
|
43 */
|
Chris@16
|
44 class current_process_name :
|
Chris@16
|
45 public constant< std::string >
|
Chris@16
|
46 {
|
Chris@16
|
47 typedef constant< std::string > base_type;
|
Chris@16
|
48
|
Chris@16
|
49 public:
|
Chris@16
|
50 /*!
|
Chris@16
|
51 * Constructor. Initializes the attribute with the current process name.
|
Chris@16
|
52 */
|
Chris@16
|
53 current_process_name() : base_type(boost::log::aux::get_process_name()) {}
|
Chris@16
|
54 /*!
|
Chris@16
|
55 * Constructor for casting support
|
Chris@16
|
56 */
|
Chris@16
|
57 explicit current_process_name(cast_source const& source) :
|
Chris@16
|
58 base_type(source)
|
Chris@16
|
59 {
|
Chris@16
|
60 }
|
Chris@16
|
61 };
|
Chris@16
|
62
|
Chris@16
|
63 } // namespace attributes
|
Chris@16
|
64
|
Chris@16
|
65 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
66
|
Chris@16
|
67 } // namespace boost
|
Chris@16
|
68
|
Chris@16
|
69 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
70
|
Chris@16
|
71 #endif // BOOST_LOG_ATTRIBUTES_CURRENT_PROCESS_NAME_HPP_INCLUDED_
|