forked from scalingdata/gowinlog
-
Notifications
You must be signed in to change notification settings - Fork 3
/
structs.go
90 lines (78 loc) · 2 KB
/
structs.go
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package winlog
import (
"sync"
"time"
)
// Stores the common fields from a log event
type WinLogEvent struct {
// From EvtRender
ProviderName string
EventId uint64
Qualifiers uint64
Level uint64
Task uint64
Opcode uint64
Created time.Time
RecordId uint64
ProcessId uint64
ThreadId uint64
Channel string
ComputerName string
Version uint64
RenderedFieldsErr error
// From EvtFormatMessage
Msg string
LevelText string
TaskText string
OpcodeText string
Keywords string
ChannelText string
ProviderText string
IdText string
PublisherHandleErr error
// Serialied XML bookmark to
// restart at this event
Bookmark string
// Subscribed channel from which the event was retrieved,
// which may be different than the event's channel
SubscribedChannel string
}
type channelWatcher struct {
subscription ListenerHandle
callback *LogEventCallbackWrapper
bookmark BookmarkHandle
}
// Watches one or more event log channels
// and publishes events and errors to Go
// channels
type WinLogWatcher struct {
errChan chan error
eventChan chan *WinLogEvent
renderContext SysRenderContext
watches map[string]*channelWatcher
watchMutex sync.Mutex
shutdown chan interface{}
// Optionally render localized fields. EvtFormatMessage() is slow, so
// skipping these fields provides a big speedup.
RenderKeywords bool
RenderMessage bool
RenderLevel bool
RenderTask bool
RenderProvider bool
RenderOpcode bool
RenderChannel bool
RenderId bool
}
type SysRenderContext uint64
type ListenerHandle uint64
type PublisherHandle uint64
type EventHandle uint64
type BookmarkHandle uint64
type LogEventCallback interface {
PublishError(error)
PublishEvent(EventHandle, string)
}
type LogEventCallbackWrapper struct {
callback LogEventCallback
subscribedChannel string
}