forked from cloudfoundry/statsd-injector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (36 loc) · 1.11 KB
/
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
44
package main
import (
"flag"
"github.com/cloudfoundry/gosteno"
"github.com/cloudfoundry/sonde-go/events"
"github.com/cloudfoundry/statsd-injector/statsdemitter"
"github.com/cloudfoundry/statsd-injector/statsdlistener"
"os"
)
var (
statsdPort = flag.Uint("statsdPort", 8125, "The UDP port the injector will listen on for statsd messages")
metronPort = flag.Uint("metronPort", 51161, "The UDP port the injector will forward message to")
logLevel = flag.String("logLevel", "info", "The logging level")
)
func main() {
flag.Parse()
level, err := gosteno.GetLogLevel(*logLevel)
if err != nil {
level = gosteno.LOG_INFO
}
loggingConfig := &gosteno.Config{
Sinks: []gosteno.Sink{
gosteno.NewIOSink(os.Stdout),
},
Level: level,
Codec: gosteno.NewJsonCodec(),
EnableLOC: true,
}
gosteno.Init(loggingConfig)
logger := gosteno.NewLogger("statsdinjector")
statsdMessageListener := statsdlistener.New(*statsdPort, logger)
statsdEmitter := statsdemitter.New(*metronPort, logger)
inputChan := make(chan *events.Envelope)
go statsdMessageListener.Run(inputChan)
statsdEmitter.Run(inputChan)
}