2 * Copyright Andrey Semashev 2007 - 2015.
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 time_traits.hpp
9 * \author Andrey Semashev
12 * The header contains implementation of time traits that are used in various parts of the
13 * library to acquire current time.
16 #ifndef BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_
17 #define BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_
19 #include <boost/date_time/posix_time/posix_time_types.hpp>
20 #include <boost/log/detail/config.hpp>
21 #include <boost/log/detail/header.hpp>
23 #ifdef BOOST_HAS_PRAGMA_ONCE
29 BOOST_LOG_OPEN_NAMESPACE
31 namespace attributes {
33 //! Base class for time traits involving Boost.DateTime.
34 struct basic_time_traits
37 typedef posix_time::ptime time_type;
39 //! Current time source
40 #if defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
41 typedef posix_time::microsec_clock clock_source;
43 typedef posix_time::second_clock clock_source;
44 #endif // defined(BOOST_DATE_TIME_HAS_HIGH_PRECISION_CLOCK)
47 //! Time traits that describes UTC time acquirement via Boost.DateTime facilities
48 struct utc_time_traits :
49 public basic_time_traits
52 * \return Current time stamp
54 static time_type get_clock()
56 return clock_source::universal_time();
60 //! Time traits that describes local time acquirement via Boost.DateTime facilities
61 struct local_time_traits :
62 public basic_time_traits
65 * \return Current time stamp
67 static time_type get_clock()
69 return clock_source::local_time();
73 } // namespace attributes
75 BOOST_LOG_CLOSE_NAMESPACE // namespace log
79 #include <boost/log/detail/footer.hpp>
81 #endif // BOOST_LOG_ATTRIBUTES_TIME_TRAITS_HPP_INCLUDED_