forked from anqin/trident
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc_tracer.h
More file actions
62 lines (49 loc) · 1.33 KB
/
func_tracer.h
File metadata and controls
62 lines (49 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (c) 2014 The Trident Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
//
#ifndef _TRIDENT_FUNC_TRACER_H_
#define _TRIDENT_FUNC_TRACER_H_
#include <boost/current_function.hpp>
#include <trident/common_internal.h>
namespace trident {
namespace internal {
class FuncTracer
{
public:
FuncTracer(const char* file, size_t line, const char* func)
: _file(file)
, _line(line)
, _func(func)
{
#if 0
LOG(INFO) << _file << ": " << _line << ": >" << _func << "()";
#else
SLOG(TRACE, "%s: %u: >%s()", _file, _line, _func);
#endif
}
~FuncTracer()
{
#if 0
LOG(INFO) << _file << ": " << _line << ": <" << _func << "()";
#else
SLOG(TRACE, "%s: %u: <%s()", _file, _line, _func);
#endif
}
private:
const char* _file;
size_t _line;
const char* _func;
}; // class Tracer
} // namespace internal
} // namespace trident
#if defined( TRIDENT_ENABLE_FUNCTION_TRACE )
# define TRIDENT_FUNCTION_TRACE \
::trident::internal::FuncTracer __trident_function_tracer__( \
__FILE__, __LINE__, BOOST_CURRENT_FUNCTION)
#else
# define TRIDENT_FUNCTION_TRACE
#endif // defined( TRIDENT_ENABLE_FUNCTION_TRACE )
#endif // _TRIDENT_FUNC_TRACER_H_
/* vim: set ts=4 sw=4 sts=4 tw=100 */