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
|
Chris@16
|
9 * \author Andrey Semashev
|
Chris@16
|
10 * \date 24.06.2007
|
Chris@16
|
11 *
|
Chris@16
|
12 * The header contains implementation of named scope container and an attribute that allows to
|
Chris@16
|
13 * put the named scope to log. A number of convenience macros are also provided.
|
Chris@16
|
14 */
|
Chris@16
|
15
|
Chris@16
|
16 #ifndef BOOST_LOG_ATTRIBUTES_NAMED_SCOPE_HPP_INCLUDED_
|
Chris@16
|
17 #define BOOST_LOG_ATTRIBUTES_NAMED_SCOPE_HPP_INCLUDED_
|
Chris@16
|
18
|
Chris@16
|
19 #include <ostream>
|
Chris@16
|
20 #include <memory>
|
Chris@16
|
21 #include <iterator>
|
Chris@16
|
22 #include <cstddef>
|
Chris@16
|
23 #include <boost/log/detail/config.hpp>
|
Chris@16
|
24 #include <boost/current_function.hpp>
|
Chris@16
|
25 #include <boost/mpl/if.hpp>
|
Chris@16
|
26 #include <boost/log/utility/string_literal.hpp>
|
Chris@16
|
27 #include <boost/log/utility/unique_identifier_name.hpp>
|
Chris@16
|
28 #include <boost/log/utility/unused_variable.hpp>
|
Chris@16
|
29 #include <boost/log/attributes/attribute.hpp>
|
Chris@16
|
30 #include <boost/log/attributes/attribute_cast.hpp>
|
Chris@16
|
31 #include <boost/log/detail/header.hpp>
|
Chris@16
|
32
|
Chris@16
|
33 #ifdef BOOST_HAS_PRAGMA_ONCE
|
Chris@16
|
34 #pragma once
|
Chris@16
|
35 #endif
|
Chris@16
|
36
|
Chris@16
|
37 namespace boost {
|
Chris@16
|
38
|
Chris@16
|
39 BOOST_LOG_OPEN_NAMESPACE
|
Chris@16
|
40
|
Chris@16
|
41 namespace attributes {
|
Chris@16
|
42
|
Chris@16
|
43 namespace aux {
|
Chris@16
|
44
|
Chris@16
|
45 //! Double-linked list node
|
Chris@16
|
46 struct named_scope_list_node
|
Chris@16
|
47 {
|
Chris@16
|
48 mutable named_scope_list_node* _m_pPrev;
|
Chris@16
|
49 mutable named_scope_list_node* _m_pNext;
|
Chris@16
|
50
|
Chris@16
|
51 named_scope_list_node() BOOST_NOEXCEPT { _m_pPrev = _m_pNext = this; }
|
Chris@16
|
52 };
|
Chris@16
|
53
|
Chris@16
|
54 } // namespace aux
|
Chris@16
|
55
|
Chris@16
|
56 /*!
|
Chris@16
|
57 * \brief The structure contains all information about a named scope
|
Chris@16
|
58 *
|
Chris@16
|
59 * The named scope entries are stored as elements of \c basic_named_scope_list container, which
|
Chris@16
|
60 * in turn can be acquired either from the \c basic_named_scope attribute value or from a thread-local
|
Chris@16
|
61 * instance.
|
Chris@16
|
62 */
|
Chris@16
|
63 struct named_scope_entry
|
Chris@16
|
64 //! \cond
|
Chris@16
|
65 : public aux::named_scope_list_node
|
Chris@16
|
66 //! \endcond
|
Chris@16
|
67 {
|
Chris@16
|
68 /*!
|
Chris@101
|
69 * \brief Scope entry type
|
Chris@101
|
70 *
|
Chris@101
|
71 * Describes scope name specifics
|
Chris@101
|
72 */
|
Chris@101
|
73 enum scope_name_type
|
Chris@101
|
74 {
|
Chris@101
|
75 general, //!< The scope name contains some unstructured string that should not be interpreted by the library
|
Chris@101
|
76 function //!< The scope name contains a function signature
|
Chris@101
|
77 };
|
Chris@101
|
78
|
Chris@101
|
79 /*!
|
Chris@16
|
80 * The scope name (e.g. a function signature)
|
Chris@16
|
81 */
|
Chris@16
|
82 string_literal scope_name;
|
Chris@16
|
83 /*!
|
Chris@16
|
84 * The source file name
|
Chris@16
|
85 */
|
Chris@16
|
86 string_literal file_name;
|
Chris@16
|
87 /*!
|
Chris@16
|
88 * The line number in the source file
|
Chris@16
|
89 */
|
Chris@16
|
90 unsigned int line;
|
Chris@101
|
91 /*!
|
Chris@101
|
92 * The scope name type
|
Chris@101
|
93 */
|
Chris@101
|
94 scope_name_type type;
|
Chris@16
|
95
|
Chris@16
|
96 /*!
|
Chris@16
|
97 * Initializing constructor
|
Chris@16
|
98 *
|
Chris@16
|
99 * \post <tt>scope_name == sn && file_name == fn && line == ln</tt>
|
Chris@16
|
100 *
|
Chris@16
|
101 * \b Throws: Nothing.
|
Chris@16
|
102 */
|
Chris@101
|
103 named_scope_entry(string_literal const& sn, string_literal const& fn, unsigned int ln, scope_name_type t = general) BOOST_NOEXCEPT :
|
Chris@16
|
104 scope_name(sn),
|
Chris@16
|
105 file_name(fn),
|
Chris@101
|
106 line(ln),
|
Chris@101
|
107 type(t)
|
Chris@16
|
108 {
|
Chris@16
|
109 }
|
Chris@16
|
110 };
|
Chris@16
|
111
|
Chris@16
|
112 /*!
|
Chris@16
|
113 * \brief The class implements the list of scopes
|
Chris@16
|
114 *
|
Chris@16
|
115 * The scope list provides a read-only access to a doubly-linked list of scopes.
|
Chris@16
|
116 */
|
Chris@16
|
117 class named_scope_list
|
Chris@16
|
118 //! \cond
|
Chris@16
|
119 : protected std::allocator< named_scope_entry >
|
Chris@16
|
120 //! \endcond
|
Chris@16
|
121 {
|
Chris@16
|
122 public:
|
Chris@16
|
123 //! Allocator type
|
Chris@16
|
124 typedef std::allocator< named_scope_entry > allocator_type;
|
Chris@16
|
125
|
Chris@16
|
126 // Standard types
|
Chris@16
|
127 typedef allocator_type::value_type value_type;
|
Chris@16
|
128 typedef allocator_type::reference reference;
|
Chris@16
|
129 typedef allocator_type::const_reference const_reference;
|
Chris@16
|
130 typedef allocator_type::pointer pointer;
|
Chris@16
|
131 typedef allocator_type::const_pointer const_pointer;
|
Chris@16
|
132 typedef allocator_type::size_type size_type;
|
Chris@16
|
133 typedef allocator_type::difference_type difference_type;
|
Chris@16
|
134
|
Chris@16
|
135 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
136
|
Chris@16
|
137 protected:
|
Chris@16
|
138 //! Iterator class
|
Chris@16
|
139 #ifndef BOOST_LOG_NO_MEMBER_TEMPLATE_FRIENDS
|
Chris@16
|
140 template< bool fConstV > class iter;
|
Chris@16
|
141 template< bool fConstV > friend class iter;
|
Chris@16
|
142 #endif
|
Chris@16
|
143 template< bool fConstV >
|
Chris@16
|
144 class iter
|
Chris@16
|
145 {
|
Chris@16
|
146 friend class iter< !fConstV >;
|
Chris@16
|
147
|
Chris@16
|
148 public:
|
Chris@16
|
149 // Standard typedefs
|
Chris@16
|
150 typedef named_scope_list::difference_type difference_type;
|
Chris@16
|
151 typedef named_scope_list::value_type value_type;
|
Chris@16
|
152 typedef typename mpl::if_c<
|
Chris@16
|
153 fConstV,
|
Chris@16
|
154 named_scope_list::const_reference,
|
Chris@16
|
155 named_scope_list::reference
|
Chris@16
|
156 >::type reference;
|
Chris@16
|
157 typedef typename mpl::if_c<
|
Chris@16
|
158 fConstV,
|
Chris@16
|
159 named_scope_list::const_pointer,
|
Chris@16
|
160 named_scope_list::pointer
|
Chris@16
|
161 >::type pointer;
|
Chris@16
|
162 typedef std::bidirectional_iterator_tag iterator_category;
|
Chris@16
|
163
|
Chris@16
|
164 public:
|
Chris@16
|
165 // Constructors
|
Chris@16
|
166 iter() : m_pNode(NULL) {}
|
Chris@16
|
167 explicit iter(aux::named_scope_list_node* pNode) : m_pNode(pNode) {}
|
Chris@16
|
168 iter(iter< false > const& that) : m_pNode(that.m_pNode) {}
|
Chris@16
|
169
|
Chris@16
|
170 //! Assignment
|
Chris@16
|
171 template< bool f >
|
Chris@16
|
172 iter& operator= (iter< f > const& that)
|
Chris@16
|
173 {
|
Chris@16
|
174 m_pNode = that.m_pNode;
|
Chris@16
|
175 return *this;
|
Chris@16
|
176 }
|
Chris@16
|
177
|
Chris@16
|
178 // Comparison
|
Chris@16
|
179 template< bool f >
|
Chris@16
|
180 bool operator== (iter< f > const& that) const { return (m_pNode == that.m_pNode); }
|
Chris@16
|
181 template< bool f >
|
Chris@16
|
182 bool operator!= (iter< f > const& that) const { return (m_pNode != that.m_pNode); }
|
Chris@16
|
183
|
Chris@16
|
184 // Modification
|
Chris@16
|
185 iter& operator++ ()
|
Chris@16
|
186 {
|
Chris@16
|
187 m_pNode = m_pNode->_m_pNext;
|
Chris@16
|
188 return *this;
|
Chris@16
|
189 }
|
Chris@16
|
190 iter& operator-- ()
|
Chris@16
|
191 {
|
Chris@16
|
192 m_pNode = m_pNode->_m_pPrev;
|
Chris@16
|
193 return *this;
|
Chris@16
|
194 }
|
Chris@16
|
195 iter operator++ (int)
|
Chris@16
|
196 {
|
Chris@16
|
197 iter tmp(*this);
|
Chris@16
|
198 m_pNode = m_pNode->_m_pNext;
|
Chris@16
|
199 return tmp;
|
Chris@16
|
200 }
|
Chris@16
|
201 iter operator-- (int)
|
Chris@16
|
202 {
|
Chris@16
|
203 iter tmp(*this);
|
Chris@16
|
204 m_pNode = m_pNode->_m_pPrev;
|
Chris@16
|
205 return tmp;
|
Chris@16
|
206 }
|
Chris@16
|
207
|
Chris@16
|
208 // Dereferencing
|
Chris@16
|
209 pointer operator-> () const { return static_cast< pointer >(m_pNode); }
|
Chris@16
|
210 reference operator* () const { return *static_cast< pointer >(m_pNode); }
|
Chris@16
|
211
|
Chris@16
|
212 private:
|
Chris@16
|
213 aux::named_scope_list_node* m_pNode;
|
Chris@16
|
214 };
|
Chris@16
|
215
|
Chris@16
|
216 public:
|
Chris@16
|
217 typedef iter< true > const_iterator;
|
Chris@16
|
218 typedef iter< false > iterator;
|
Chris@16
|
219 typedef std::reverse_iterator< const_iterator > const_reverse_iterator;
|
Chris@16
|
220 typedef std::reverse_iterator< iterator > reverse_iterator;
|
Chris@16
|
221
|
Chris@16
|
222 protected:
|
Chris@16
|
223 //! The root node of the container
|
Chris@16
|
224 aux::named_scope_list_node m_RootNode;
|
Chris@16
|
225 //! The size of the container
|
Chris@16
|
226 size_type m_Size;
|
Chris@16
|
227 //! The flag shows if the contained elements are dynamically allocated
|
Chris@16
|
228 bool m_fNeedToDeallocate;
|
Chris@16
|
229
|
Chris@16
|
230 #else // BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
231
|
Chris@16
|
232 /*!
|
Chris@16
|
233 * A constant iterator to the sequence of scopes. Complies to bidirectional iterator requirements.
|
Chris@16
|
234 */
|
Chris@16
|
235 typedef implementation_defined const_iterator;
|
Chris@16
|
236 /*!
|
Chris@16
|
237 * An iterator to the sequence of scopes. Complies to bidirectional iterator requirements.
|
Chris@16
|
238 */
|
Chris@16
|
239 typedef implementation_defined iterator;
|
Chris@16
|
240 /*!
|
Chris@16
|
241 * A constant reverse iterator to the sequence of scopes. Complies to bidirectional iterator requirements.
|
Chris@16
|
242 */
|
Chris@16
|
243 typedef implementation_defined const_reverse_iterator;
|
Chris@16
|
244 /*!
|
Chris@16
|
245 * A reverse iterator to the sequence of scopes. Complies to bidirectional iterator requirements.
|
Chris@16
|
246 */
|
Chris@16
|
247 typedef implementation_defined reverse_iterator;
|
Chris@16
|
248
|
Chris@16
|
249 #endif // BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
250
|
Chris@16
|
251 public:
|
Chris@16
|
252 /*!
|
Chris@16
|
253 * Default constructor
|
Chris@16
|
254 *
|
Chris@16
|
255 * \post <tt>empty() == true</tt>
|
Chris@16
|
256 */
|
Chris@16
|
257 named_scope_list() : m_Size(0), m_fNeedToDeallocate(false) {}
|
Chris@16
|
258 /*!
|
Chris@16
|
259 * Copy constructor
|
Chris@16
|
260 *
|
Chris@16
|
261 * \post <tt>std::equal(begin(), end(), that.begin()) == true</tt>
|
Chris@16
|
262 */
|
Chris@16
|
263 BOOST_LOG_API named_scope_list(named_scope_list const& that);
|
Chris@16
|
264 /*!
|
Chris@16
|
265 * Destructor. Destroys the stored entries.
|
Chris@16
|
266 */
|
Chris@16
|
267 BOOST_LOG_API ~named_scope_list();
|
Chris@16
|
268
|
Chris@16
|
269 /*!
|
Chris@16
|
270 * Assignment operator
|
Chris@16
|
271 *
|
Chris@16
|
272 * \post <tt>std::equal(begin(), end(), that.begin()) == true</tt>
|
Chris@16
|
273 */
|
Chris@16
|
274 named_scope_list& operator= (named_scope_list const& that)
|
Chris@16
|
275 {
|
Chris@16
|
276 if (this != &that)
|
Chris@16
|
277 {
|
Chris@16
|
278 named_scope_list tmp(that);
|
Chris@16
|
279 swap(tmp);
|
Chris@16
|
280 }
|
Chris@16
|
281 return *this;
|
Chris@16
|
282 }
|
Chris@16
|
283
|
Chris@16
|
284 /*!
|
Chris@16
|
285 * \return Constant iterator to the first element of the container.
|
Chris@16
|
286 */
|
Chris@16
|
287 const_iterator begin() const { return const_iterator(m_RootNode._m_pNext); }
|
Chris@16
|
288 /*!
|
Chris@16
|
289 * \return Constant iterator to the after-the-last element of the container.
|
Chris@16
|
290 */
|
Chris@16
|
291 const_iterator end() const { return const_iterator(const_cast< aux::named_scope_list_node* >(&m_RootNode)); }
|
Chris@16
|
292 /*!
|
Chris@16
|
293 * \return Constant iterator to the last element of the container.
|
Chris@16
|
294 */
|
Chris@16
|
295 const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
|
Chris@16
|
296 /*!
|
Chris@16
|
297 * \return Constant iterator to the before-the-first element of the container.
|
Chris@16
|
298 */
|
Chris@16
|
299 const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
|
Chris@16
|
300
|
Chris@16
|
301 /*!
|
Chris@16
|
302 * \return The number of elements in the container
|
Chris@16
|
303 */
|
Chris@16
|
304 size_type size() const { return m_Size; }
|
Chris@16
|
305 /*!
|
Chris@16
|
306 * \return true if the container is empty and false otherwise
|
Chris@16
|
307 */
|
Chris@16
|
308 bool empty() const { return (m_Size == 0); }
|
Chris@16
|
309
|
Chris@16
|
310 /*!
|
Chris@16
|
311 * Swaps two instances of the container
|
Chris@16
|
312 */
|
Chris@16
|
313 BOOST_LOG_API void swap(named_scope_list& that);
|
Chris@16
|
314
|
Chris@16
|
315 /*!
|
Chris@16
|
316 * \return Last pushed scope entry
|
Chris@16
|
317 */
|
Chris@16
|
318 const_reference back() const { return *rbegin(); }
|
Chris@16
|
319 /*!
|
Chris@16
|
320 * \return First pushed scope entry
|
Chris@16
|
321 */
|
Chris@16
|
322 const_reference front() const { return *begin(); }
|
Chris@16
|
323 };
|
Chris@16
|
324
|
Chris@16
|
325 //! Stream output operator
|
Chris@16
|
326 template< typename CharT, typename TraitsT >
|
Chris@16
|
327 inline std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream< CharT, TraitsT >& strm, named_scope_list const& sl)
|
Chris@16
|
328 {
|
Chris@16
|
329 if (strm.good())
|
Chris@16
|
330 {
|
Chris@16
|
331 named_scope_list::const_iterator it = sl.begin(), end = sl.end();
|
Chris@16
|
332 if (it != end)
|
Chris@16
|
333 {
|
Chris@16
|
334 strm << it->scope_name.c_str();
|
Chris@16
|
335 for (++it; it != end; ++it)
|
Chris@16
|
336 strm << "->" << it->scope_name.c_str();
|
Chris@16
|
337 }
|
Chris@16
|
338 }
|
Chris@16
|
339 return strm;
|
Chris@16
|
340 }
|
Chris@16
|
341
|
Chris@16
|
342 /*!
|
Chris@16
|
343 * \brief A class of an attribute that holds stack of named scopes of the current thread
|
Chris@16
|
344 *
|
Chris@16
|
345 * The basic_named_scope attribute is essentially a hook to the thread-specific instance of
|
Chris@16
|
346 * scope list. This means that the attribute will generate different values if get_value is
|
Chris@16
|
347 * called in different threads. The attribute generates value with stored type
|
Chris@16
|
348 * <tt>basic_named_scope_list< CharT ></tt>.
|
Chris@16
|
349 *
|
Chris@16
|
350 * The attribute class can also be used to gain access to the scope stack instance, e.g. to
|
Chris@16
|
351 * get its copy or to push or pop a scope entry. However, it is highly not recommended to
|
Chris@16
|
352 * maintain scope list manually. Use \c BOOST_LOG_NAMED_SCOPE or \c BOOST_LOG_FUNCTION macros instead.
|
Chris@16
|
353 */
|
Chris@16
|
354 class BOOST_LOG_API named_scope :
|
Chris@16
|
355 public attribute
|
Chris@16
|
356 {
|
Chris@16
|
357 public:
|
Chris@16
|
358 //! Scope names stack (the attribute value type)
|
Chris@16
|
359 typedef named_scope_list value_type;
|
Chris@16
|
360 //! Scope entry
|
Chris@16
|
361 typedef value_type::value_type scope_entry;
|
Chris@16
|
362
|
Chris@16
|
363 //! Sentry object class to automatically push and pop scopes
|
Chris@16
|
364 struct sentry
|
Chris@16
|
365 {
|
Chris@16
|
366 /*!
|
Chris@16
|
367 * Constructor. Pushes the specified scope to the end of the thread-local list of scopes.
|
Chris@16
|
368 *
|
Chris@16
|
369 * \param sn Scope name.
|
Chris@16
|
370 * \param fn File name, in which the scope is located.
|
Chris@16
|
371 * \param ln Line number in the file.
|
Chris@16
|
372 */
|
Chris@101
|
373 sentry(string_literal const& sn, string_literal const& fn, unsigned int ln, scope_entry::scope_name_type t = scope_entry::general) BOOST_NOEXCEPT :
|
Chris@101
|
374 m_Entry(sn, fn, ln, t)
|
Chris@16
|
375 {
|
Chris@16
|
376 named_scope::push_scope(m_Entry);
|
Chris@16
|
377 }
|
Chris@16
|
378
|
Chris@16
|
379 /*!
|
Chris@16
|
380 * Destructor. Removes the last pushed scope from the thread-local list of scopes.
|
Chris@16
|
381 */
|
Chris@16
|
382 ~sentry() BOOST_NOEXCEPT
|
Chris@16
|
383 {
|
Chris@16
|
384 named_scope::pop_scope();
|
Chris@16
|
385 }
|
Chris@16
|
386
|
Chris@16
|
387 BOOST_DELETED_FUNCTION(sentry(sentry const&))
|
Chris@16
|
388 BOOST_DELETED_FUNCTION(sentry& operator= (sentry const&))
|
Chris@16
|
389
|
Chris@16
|
390 private:
|
Chris@16
|
391 scope_entry m_Entry;
|
Chris@16
|
392 };
|
Chris@16
|
393
|
Chris@16
|
394 private:
|
Chris@16
|
395 //! Attribute implementation class
|
Chris@16
|
396 struct BOOST_SYMBOL_VISIBLE impl;
|
Chris@16
|
397
|
Chris@16
|
398 public:
|
Chris@16
|
399 /*!
|
Chris@16
|
400 * Constructor. Creates an attribute.
|
Chris@16
|
401 */
|
Chris@16
|
402 named_scope();
|
Chris@16
|
403 /*!
|
Chris@16
|
404 * Constructor for casting support
|
Chris@16
|
405 */
|
Chris@16
|
406 explicit named_scope(cast_source const& source);
|
Chris@16
|
407
|
Chris@16
|
408 /*!
|
Chris@16
|
409 * The method pushes the scope to the back of the current thread's scope list
|
Chris@16
|
410 *
|
Chris@16
|
411 * \b Throws: Nothing.
|
Chris@16
|
412 */
|
Chris@16
|
413 static void push_scope(scope_entry const& entry) BOOST_NOEXCEPT;
|
Chris@16
|
414 /*!
|
Chris@16
|
415 * The method pops the last pushed scope from the current thread's scope list
|
Chris@16
|
416 *
|
Chris@16
|
417 * \b Throws: Nothing.
|
Chris@16
|
418 */
|
Chris@16
|
419 static void pop_scope() BOOST_NOEXCEPT;
|
Chris@16
|
420
|
Chris@16
|
421 /*!
|
Chris@16
|
422 * \return The current thread's list of scopes
|
Chris@16
|
423 *
|
Chris@16
|
424 * \note The returned reference is only valid until the current thread ends. The scopes in the
|
Chris@16
|
425 * returned container may change if the execution scope is changed (i.e. either \c push_scope
|
Chris@16
|
426 * or \c pop_scope is called). User has to copy the stack if he wants to keep it intact regardless
|
Chris@16
|
427 * of the execution scope.
|
Chris@16
|
428 */
|
Chris@16
|
429 static value_type const& get_scopes();
|
Chris@16
|
430 };
|
Chris@16
|
431
|
Chris@16
|
432 } // namespace attributes
|
Chris@16
|
433
|
Chris@16
|
434 BOOST_LOG_CLOSE_NAMESPACE // namespace log
|
Chris@16
|
435
|
Chris@16
|
436 } // namespace boost
|
Chris@16
|
437
|
Chris@16
|
438 #ifndef BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
439
|
Chris@101
|
440 #define BOOST_LOG_NAMED_SCOPE_INTERNAL(var, name, file, line, type)\
|
Chris@101
|
441 BOOST_LOG_UNUSED_VARIABLE(::boost::log::attributes::named_scope::sentry, var, (name, file, line, type));
|
Chris@16
|
442
|
Chris@16
|
443 #endif // BOOST_LOG_DOXYGEN_PASS
|
Chris@16
|
444
|
Chris@16
|
445 /*!
|
Chris@16
|
446 * Macro for scope markup. The specified scope name is pushed to the end of the current thread scope list.
|
Chris@16
|
447 */
|
Chris@16
|
448 #define BOOST_LOG_NAMED_SCOPE(name)\
|
Chris@101
|
449 BOOST_LOG_NAMED_SCOPE_INTERNAL(BOOST_LOG_UNIQUE_IDENTIFIER_NAME(_boost_log_named_scope_sentry_), name, __FILE__, __LINE__, ::boost::log::attributes::named_scope_entry::general)
|
Chris@16
|
450
|
Chris@16
|
451 /*!
|
Chris@101
|
452 * Macro for function scope markup. The scope name is constructed with help of compiler and contains the current function signature.
|
Chris@16
|
453 * The scope name is pushed to the end of the current thread scope list.
|
Chris@16
|
454 *
|
Chris@16
|
455 * Not all compilers have support for this macro. The exact form of the scope name may vary from one compiler to another.
|
Chris@16
|
456 */
|
Chris@101
|
457 #define BOOST_LOG_FUNCTION()\
|
Chris@101
|
458 BOOST_LOG_NAMED_SCOPE_INTERNAL(BOOST_LOG_UNIQUE_IDENTIFIER_NAME(_boost_log_named_scope_sentry_), BOOST_CURRENT_FUNCTION, __FILE__, __LINE__, ::boost::log::attributes::named_scope_entry::function)
|
Chris@101
|
459
|
Chris@101
|
460 /*!
|
Chris@101
|
461 * Macro for function scope markup. The scope name is constructed with help of compiler and contains the current function name. It may be shorter than what \c BOOST_LOG_FUNCTION macro produces.
|
Chris@101
|
462 * The scope name is pushed to the end of the current thread scope list.
|
Chris@101
|
463 *
|
Chris@101
|
464 * Not all compilers have support for this macro. The exact form of the scope name may vary from one compiler to another.
|
Chris@101
|
465 */
|
Chris@101
|
466 #if defined(_MSC_VER) || defined(__GNUC__)
|
Chris@101
|
467 #define BOOST_LOG_FUNC() BOOST_LOG_NAMED_SCOPE(__FUNCTION__)
|
Chris@101
|
468 #else
|
Chris@101
|
469 #define BOOST_LOG_FUNC() BOOST_LOG_FUNCTION()
|
Chris@101
|
470 #endif
|
Chris@16
|
471
|
Chris@16
|
472 #include <boost/log/detail/footer.hpp>
|
Chris@16
|
473
|
Chris@16
|
474 #endif // BOOST_LOG_ATTRIBUTES_NAMED_SCOPE_HPP_INCLUDED_
|