forked from deep-compute/docker-file-log-driver
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
37 lines (32 loc) · 798 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
package main
import (
"fmt"
"os"
"github.com/sirupsen/logrus"
"github.com/docker/go-plugins-helpers/sdk"
"github.com/exo-docker/docker-file-log-driver/driver"
"github.com/exo-docker/docker-file-log-driver/http"
)
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)
} else {
fmt.Fprintln(os.Stderr, "invalid log level: ", levelVal)
os.Exit(1)
}
h := sdk.NewHandler(`{"Implements": ["LoggingDriver"]}`)
http.Handlers(&h, driver.NewDriver())
if err := h.ServeUnix("log", 0); err != nil {
panic(err)
}
}