Skip to content

Commit d380e92

Browse files
committed
SCFF-34 logging modifications
1 parent 305563b commit d380e92

4 files changed

Lines changed: 15 additions & 13 deletions

File tree

eventRouting/eventrouting.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/caching"
1111
"bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventQueue"
1212
fevents "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/events"
13-
"bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/logging"
1413
"bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/sumoCFFirehose"
1514
"github.com/Sirupsen/logrus"
1615
"github.com/cloudfoundry/sonde-go/events"
@@ -77,10 +76,8 @@ func (e *EventRouting) RouteEvent(msg *events.Envelope) {
7776
e.selectedEventsCount["ignored_app_message"]++
7877
} else {
7978
//Push the event to the queue
80-
logging.Info.Println("pushing event to queue")
8179
e.queue.Push(event)
8280
e.selectedEventsCount[eventType.String()]++
83-
8481
}
8582
e.mutex.Unlock()
8683
}

firehoseclient/firehoseclient.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package firehoseclient
22

33
import (
44
"crypto/tls"
5-
"fmt"
65
"time"
76

87
"bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventRouting"
8+
"bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/logging"
99
"github.com/cloudfoundry-community/go-cfclient"
1010
"github.com/cloudfoundry/noaa/consumer"
1111
"github.com/cloudfoundry/sonde-go/events"
@@ -43,11 +43,10 @@ func NewFirehoseNozzle(cfClient *cfclient.Client, eventRouting *eventRouting.Eve
4343
}
4444

4545
func (f *FirehoseNozzle) Start() error {
46-
fmt.Printf("Started the Nozzle... \n")
46+
logging.Info.Printf("Started the Nozzle... \n")
4747
f.consumeFirehose()
48-
fmt.Printf("consume the firehose... \n")
48+
logging.Info.Printf("consume the firehose... \n")
4949
err := f.routeEvent()
50-
fmt.Printf("route event... \n")
5150
return err
5251
}
5352

main.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ func main() {
4747

4848
runtime.GOMAXPROCS(1)
4949

50+
logging.Info.Println("Configurations set:")
51+
logging.Info.Println("Api Endpoint: " + apiEndpoint)
52+
logging.Info.Println("Sumo Endpoint: " + *sumoEndpoint)
53+
logging.Info.Println("User: " + user)
54+
logging.Info.Printf("Events Batch Size: [%d]\n", eventsBatchSize)
55+
5056
logging.Info.Println("Starting firehose-to-sumo " + version)
5157

5258
c := cfclient.Config{
@@ -69,12 +75,12 @@ func main() {
6975
cachingClient = caching.NewCachingEmpty()
7076
}
7177

72-
//Creating queue
78+
logging.Info.Println("Creating queue")
7379
queue := eventQueue.NewQueue(make([]*events.Event, 100))
7480
loggingClientSumo := sumoCFFirehose.NewSumoLogicAppender(*sumoEndpoint, 1000, &queue, *eventsBatchSize)
7581
go loggingClientSumo.Start() //multi
7682

77-
//Creating Events
83+
logging.Info.Println("Creating Events")
7884
events := eventRouting.NewEventRouting(cachingClient, *loggingClientSumo, &queue)
7985
err := events.SetupEventRouting(*wantedEvents)
8086
if err != nil {

sumoCFFirehose/sumoLogicAppender.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ func (s *SumoLogicAppender) Start() {
4141
s.AppendLogs()
4242
}
4343
if s.logEventsInCurrentBuffer >= s.eventsBatchSize { //if buffer is full, send logs to sumo
44-
logging.Info.Println("Buffer full")
44+
logging.Trace.Println("Batch Size complete")
4545
s.SendToSumo(s.logStringToSend)
4646

4747
} else if time.Since(timer).Seconds() >= 10 { // else if timer is up, send existing logs to sumo
48-
logging.Info.Println("timer finished")
48+
logging.Trace.Println("Sending current batch of logs after timer exceeded limit")
4949
s.SendToSumo(s.logStringToSend)
5050
timer = time.Now() //reset timer
5151
}
@@ -75,7 +75,7 @@ func (s *SumoLogicAppender) AppendLogs() {
7575
}
7676

7777
func (s *SumoLogicAppender) SendToSumo(log *bytes.Buffer) {
78-
logging.Info.Println("Sending logs to Sumologic...")
78+
logging.Trace.Println("Sending logs to Sumologic...")
7979
request, err := http.NewRequest("POST", s.url, log)
8080
if err != nil {
8181
logging.Error.Printf("http.NewRequest() error: %v\n", err)
@@ -89,7 +89,7 @@ func (s *SumoLogicAppender) SendToSumo(log *bytes.Buffer) {
8989
logging.Error.Printf("http.Do() error: %v\n", err)
9090
return
9191
} else {
92-
logging.Info.Println("Do(Request) successful")
92+
logging.Trace.Println("Do(Request) successful")
9393
}
9494
s.logEventsInCurrentBuffer = 0 // reset counter
9595
s.logStringToSend = bytes.NewBufferString("") //reset String

0 commit comments

Comments
 (0)