forked from microsoft/CLRInstrumentationEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventLoggerSink.cpp
68 lines (52 loc) · 1.47 KB
/
EventLoggerSink.cpp
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
63
64
65
66
67
68
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "stdafx.h"
#include "EventLoggerSink.h"
using namespace MicrosoftInstrumentationEngine;
CEventLoggerSink::CEventLoggerSink() :
m_initEventSource([=]() { return InitializeEventSource(_T("Instrumentation Engine")); })
{
}
CEventLoggerSink::~CEventLoggerSink()
{
}
HRESULT CEventLoggerSink::Initialize(_In_ CLoggerService* pLogging)
{
return S_OK;
}
void CEventLoggerSink::LogMessage(_In_ LPCWSTR wszMessage)
{
// Ignore messages
}
void CEventLoggerSink::LogError(_In_ LPCWSTR wszMessage)
{
AppendToQueue(EVENTLOG_ERROR_TYPE, wszMessage);
}
void CEventLoggerSink::LogDumpMessage(_In_ LPCWSTR wszMessage)
{
// Ignore dump messages
}
HRESULT CEventLoggerSink::Reset(_In_ LoggingFlags defaultFlags, _Out_ LoggingFlags* pEffectiveFlags)
{
if (!pEffectiveFlags)
{
return E_POINTER;
}
*pEffectiveFlags = LoggingFlags_None;
// Only allow errors to be sent to event log
LoggingFlags effectiveFlags = static_cast<LoggingFlags>(defaultFlags & LoggingFlags_Errors);
// Only start event source thread if logging has been enabled
if (LoggingFlags_None != effectiveFlags)
{
HRESULT hr = S_OK;
IfFailRetNoLog(m_initEventSource.Get());
}
*pEffectiveFlags = effectiveFlags;
return S_OK;
}
HRESULT CEventLoggerSink::Shutdown()
{
HRESULT hr = TerminateEventSource();
m_initEventSource.Reset();
return hr;
}