-
Notifications
You must be signed in to change notification settings - Fork 2
/
example-etw-provider.cc
34 lines (26 loc) · 1.22 KB
/
example-etw-provider.cc
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
// Copyright 2019 Bill Ticehurst. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "./example-etw-provider.h"
#include <string>
namespace example {
ExampleEtwProvider::ExampleEtwProvider()
: EtwProvider(example_provider_guid, example_provider_name) {}
ExampleEtwProvider& ExampleEtwProvider::GetProvider() {
// The below pattern means the destructor will not run at process exit. (Which
// is unnecessary anyway as the provider will unregister at process exit).
// See "Static and Global Variables" in https://google.github.io/styleguide/cppguide.html
static ExampleEtwProvider &the_provider = *(new ExampleEtwProvider());
return the_provider;
}
// Any non-trivial logging should be a separate function call, not inlined
void ExampleEtwProvider::Log3Fields(int val,
const std::string& msg, void* addr) {
constexpr static auto event_desc = EventDescriptor(100);
constexpr static auto event_meta = EventMetadata("my1stEvent",
Field("MyIntVal", etw::kTypeInt32),
Field("MyMsg", etw::kTypeAnsiStr),
Field("Address", etw::kTypePointer));
LogEventData(&event_desc, &event_meta, val, msg, addr);
}
} // namespace example