-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpl.go
59 lines (54 loc) · 2.17 KB
/
rpl.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
// Package rpl, the Remote Procedure Logger.
//
// # Introduction
//
// RPL is a lite logger utility which supports serialize its Log object,
// making it easy to show log in remote procedure.
//
// # Overview
//
// Here's a typical RPL logging workflow:
//
// ---------------------------------------------------------------
// | | |
// | R E M O T E | L O C A L |
// | | |
// | Logger ----- Sender ------|--- Receiver ----- FileTarget |
// | \ | \ | |
// | \ | \ | |
// | \ | \ (Write to |
// | EventLogTarget | FileTarget os.Stdout) |
// | | | | |
// | | | | |
// | (Write to Windows | (Write to log |
// | Event Log) | file) |
// | | |
// ---------------------------------------------------------------
//
// RPL consists of 3 basic types:
// Log, Target and Source.
//
// - Log transfers as plain old data, between remote and local.
// - Target is the output (local) or sender (remote) of Source.
// - Source is the log producer (remote), or receiver (local).
package rpl
// Log transfers as plain old data, between remote and local.
type Log struct {
Ch uint16 `json:"ch" mapstructure:"ch"`
Level int8 `json:"level" mapstructure:"level"`
Value string `json:"value" mapstructure:"value"`
}
// Target is the output (local) or sender (remote) of Source.
type Target interface {
// Writer returns the Log channel.
Writer() chan<- *Log
// Close this [rpl.Target].
Close()
}
// Source is the log producer (remote), or receiver (local).
type Source interface {
// Register a Target.
Register(target Target)
// Close this [rpl.Source] and all registered [rpl.Target]s.
Close()
}