forked from OpenApoc/OpenApoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
trace.h
42 lines (32 loc) · 876 Bytes
/
trace.h
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
#pragma once
#include "library/strings.h"
// Include logger for 'LOGGER_PREFIX' definition
#include "framework/logger.h"
#include <vector>
namespace OpenApoc
{
class Trace
{
public:
static void enable();
static void disable();
static void start(const UString &name,
const std::vector<std::pair<UString, UString>> &args = {});
static void end(const UString &end);
static bool enabled;
static void setThreadName(const UString &name);
};
class TraceObj
{
public:
UString name;
TraceObj(const UString &name, const std::vector<std::pair<UString, UString>> &args = {})
: name(name)
{
Trace::start(name, args);
}
~TraceObj() { Trace::end(name); }
};
#define TRACE_FN TraceObj trace_object_##__COUNTER__(LOGGER_PREFIX)
#define TRACE_FN_ARGS1(a, b) TraceObj trace_object_##__COUNTER__(LOGGER_PREFIX, {{a, b}})
} // namespace OpenApoc