-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
43 lines (36 loc) · 869 Bytes
/
main.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
package main
import (
"fmt"
"os"
"github.com/Sirupsen/logrus"
"github.com/docker/go-plugins-helpers/sdk"
"github.com/rchicoli/docker-log-elasticsearch/pkg/docker"
)
var logLevels = map[string]logrus.Level{
"debug": logrus.DebugLevel,
"info": logrus.InfoLevel,
"warn": logrus.WarnLevel,
"error": logrus.ErrorLevel,
}
func main() {
levelVal := os.Getenv("LOG_LEVEL")
if levelVal == "" {
levelVal = "info"
}
if level, exists := logLevels[levelVal]; exists {
logrus.SetLevel(level)
logrus.SetFormatter(&logrus.TextFormatter{
DisableTimestamp: true,
QuoteEmptyFields: false,
})
} else {
fmt.Fprintln(os.Stderr, "invalid log level: ", levelVal)
os.Exit(1)
}
h := sdk.NewHandler(`{"Implements": ["LoggingDriver"]}`)
d := docker.NewDriver()
docker.Handlers(&h, d)
if err := h.ServeUnix(d.Name(), 0); err != nil {
panic(err)
}
}