/
main.go
61 lines (51 loc) · 867 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"code.google.com/p/gcfg"
"github.com/Sirupsen/logrus"
"time"
)
const (
sleepTime = 2 * time.Second
configFile = "/etc/pglogger/pglogger.conf"
)
var log *logrus.Logger
var config Config
type Config struct {
AwsCredentials struct {
Key string
SecretKey string
}
Graphite struct {
Host string
Port int
MetricPrefix string
}
}
func sleep() {
time.Sleep(sleepTime)
}
func work() {
SendLogs(AnalyzeLogs(FetchLogs()))
}
func loadLogging() {
// XXX (mmr) : find a better way to do this
log = logrus.New()
fmt := new(logrus.TextFormatter)
fmt.FullTimestamp = true
log.Formatter = fmt
log.Level = logrus.DebugLevel
}
func loadConfig() {
gcfg.ReadFileInto(&config, configFile)
}
func init() {
loadLogging()
loadConfig()
}
func main() {
log.Info("Firing up...")
for {
work()
sleep()
}
}