@@ -2,16 +2,17 @@ package main
22
33import (
44 "fmt"
5- "log "
5+ "io/ioutil "
66 "os"
7- "time"
8-
97 "runtime"
8+ "time"
109
1110 "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/caching"
1211 "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventQueue"
1312 "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventRouting"
13+ "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/events"
1414 "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/firehoseclient"
15+ "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/logging"
1516 "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/sumoCFFirehose"
1617 "github.com/cloudfoundry-community/go-cfclient"
1718 "gopkg.in/alecthomas/kingpin.v2"
@@ -38,11 +39,15 @@ var (
3839)
3940
4041func main () {
42+ //logging init
43+ logging .Init (ioutil .Discard , os .Stdout , os .Stdout , os .Stderr )
44+
4145 kingpin .Version (version )
4246 kingpin .Parse ()
47+
4348 runtime .GOMAXPROCS (1 )
4449
45- fmt . Printf ("Starting firehose-to-sumo %s \n " , version )
50+ logging . Info . Println ("Starting firehose-to-sumo " + version )
4651
4752 c := cfclient.Config {
4853 ApiAddress : apiEndpoint ,
@@ -65,25 +70,25 @@ func main() {
6570 }
6671
6772 //Creating queue
68- queue := eventQueue .NewQueue (make ([]* eventQueue. Node , 100 ))
73+ queue := eventQueue .NewQueue (make ([]* events. Event , 100 ))
6974 loggingClientSumo := sumoCFFirehose .NewSumoLogicAppender (* sumoEndpoint , 1000 , & queue , * eventsBatchSize )
7075 go loggingClientSumo .Start () //multi
7176
7277 //Creating Events
7378 events := eventRouting .NewEventRouting (cachingClient , * loggingClientSumo , & queue )
7479 err := events .SetupEventRouting (* wantedEvents )
7580 if err != nil {
76- log .Fatal ("Error setting up event routing: " , err )
81+ logging . Error .Fatal ("Error setting up event routing: " , err )
7782 os .Exit (1 )
7883
7984 }
8085
8186 // Parse extra fields from cmd call
8287 cachingClient .CreateBucket ()
8388 //Let's Update the database the first time
84- fmt .Printf ("Start filling app/space/org cache.\n " )
89+ logging . Info .Printf ("Start filling app/space/org cache.\n " )
8590 apps := cachingClient .GetAllApp ()
86- fmt .Printf ("Done filling cache! Found [%d] Apps \n " , len (apps ))
91+ logging . Info .Printf ("Done filling cache! Found [%d] Apps \n " , len (apps ))
8792
8893 //Let's start the goRoutine
8994 cachingClient .PerformPoollingCaching (tickerTime )
@@ -95,15 +100,12 @@ func main() {
95100 FirehoseSubscriptionID : * subscriptionId ,
96101 }
97102
98- if /*loggingClientSumo.Connect() ||*/ debug {
99-
100- fmt .Printf ("Connected to Server! Connecting to Firehose... \n " )
103+ logging .Info .Printf ("Connecting to Firehose... \n " )
101104
102- firehoseClient := firehoseclient .NewFirehoseNozzle (cfClient , events , firehoseConfig )
103- go firehoseClient .Start ()
105+ firehoseClient := firehoseclient .NewFirehoseNozzle (cfClient , events , firehoseConfig )
106+ go firehoseClient .Start ()
104107
105- defer firehoseClient .Start ()
106- }
108+ defer firehoseClient .Start ()
107109
108110 defer cachingClient .Close ()
109111
0 commit comments