1 // (C) Copyright 2013 Vicente J. Botet Escriba
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_THREAD_CALL_CONTEXT_HPP
8 #define BOOST_THREAD_CALL_CONTEXT_HPP
10 #include <boost/thread/detail/config.hpp>
11 #if defined BOOST_THREAD_USES_LOG_THREAD_ID
12 #include <boost/thread/thread.hpp>
14 #include <boost/current_function.hpp>
17 #include <boost/config/abi_prefix.hpp>
22 struct caller_context_t
24 const char * filename;
27 caller_context_t(const char * filename, unsigned lineno, const char * func) :
28 filename(filename), lineno(lineno), func(func)
33 #define BOOST_CONTEXTOF boost::caller_context_t(__FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
35 template <typename OStream>
36 OStream& operator<<(OStream& os, caller_context_t const& ctx)
38 #if defined BOOST_THREAD_USES_LOG_THREAD_ID
40 io::ios_flags_saver ifs( os );
41 os << std::left << std::setw(14) << boost::this_thread::get_id() << " ";
45 io::ios_flags_saver ifs(os);
46 os << ctx.filename << "["
47 << std::setw(4) << std::right << std::dec<< ctx.lineno << "] ";
48 os << ctx.func << " " ;
54 #include <boost/config/abi_suffix.hpp>