-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlog.go
49 lines (38 loc) · 823 Bytes
/
log.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
package cloudwatch
import (
"time"
"github.com/gliderlabs/logspout/router"
)
type Log interface {
Body() string
Size() int
Timestamp() int64
}
// LogMessage represents a log message to be sent to CloudWatch.
type LogMessage struct {
*router.Message
}
// Body returns a string representation of the log.
func (l *LogMessage) Body() string {
return l.Data
}
// Size returns the size of the log message in bytes.
func (l *LogMessage) Size() int {
return len(l.Data)
}
// Timestamp returns the number of milliseconds since the epoch.
func (l *LogMessage) Timestamp() int64 {
return l.Time.UnixNano() / int64(time.Millisecond)
}
type FakeLog struct {
size int
}
func (l *FakeLog) Body() string {
return ""
}
func (l *FakeLog) Size() int {
return l.size
}
func (l *FakeLog) Timestamp() int64 {
return 0
}