Skip to content

Commit 78b2c8d

Browse files
committed
SCFF-35 Removing unnecessary logs
1 parent ec11ea1 commit 78b2c8d

1 file changed

Lines changed: 11 additions & 19 deletions

File tree

sumoCFFirehose/sumoLogicAppender.go

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,25 @@ func newBuffer() SumoBuffer {
5151
func (s *SumoLogicAppender) Start() {
5252
s.timerBetweenPost = time.Now()
5353
runtime.GOMAXPROCS(1)
54-
Buffer := newBuffer() //creating Buffer
55-
Buffer.timerIdlebuffer = time.Now() //starting timerPostMinimum
54+
Buffer := newBuffer()
55+
fmt.Printf("First Buffer Reference: %v \n", &Buffer)
56+
Buffer.timerIdlebuffer = time.Now()
5657
msgFromChannel := ""
5758
logging.Info.Println("Starting Appender Worker")
5859
for {
59-
fmt.Println("first for")
60-
time.Sleep(300 * time.Millisecond) //delay
61-
if Buffer.logEventsInCurrentBuffer >= s.eventsBatchSize || msgFromChannel == "Buffer being sent" { //if buffer is full, create a new one
62-
fmt.Println("Creating new Buffer")
63-
fmt.Println(Buffer.logEventsInCurrentBuffer)
64-
fmt.Println(msgFromChannel)
60+
time.Sleep(300 * time.Millisecond)
61+
if Buffer.logEventsInCurrentBuffer >= s.eventsBatchSize || msgFromChannel == "Buffer being sent" {
6562
Buffer = newBuffer()
6663
}
67-
//mutex.Lock() //lock mutex to ensure exclusive access to buffer
68-
// while queue is not empty && s.eventsBatchSize not completed, queue.POP (appendLogs)
64+
6965
for s.nozzleQueue.GetCount() != 0 && Buffer.logEventsInCurrentBuffer < s.eventsBatchSize {
70-
fmt.Println("second for")
71-
s.AppendLogs(&Buffer) //this method POP an event from queue to Buffer
72-
Buffer.timerIdlebuffer = time.Now() //reset buffer timer, buffer has new content
73-
if Buffer.logEventsInCurrentBuffer == s.eventsBatchSize { //if buffer is full, send logs to sumo
66+
s.AppendLogs(&Buffer)
67+
time.Sleep(300 * time.Millisecond)
68+
Buffer.timerIdlebuffer = time.Now()
69+
if Buffer.logEventsInCurrentBuffer == s.eventsBatchSize {
7470
logging.Info.Println("Batch Size complete")
7571
break
76-
} else if time.Since(Buffer.timerIdlebuffer).Seconds() >= 10 { // else if buffer timer is up, send existing logs to sumo
72+
} else if time.Since(Buffer.timerIdlebuffer).Seconds() >= 10 {
7773
logging.Info.Println("Sending current batch of logs after timer exceeded limit")
7874
break
7975
}
@@ -105,17 +101,13 @@ func StringBuilder(event *events.Event) string {
105101
}
106102

107103
func (s *SumoLogicAppender) AppendLogs(buffer *SumoBuffer) {
108-
// the appender calls for the next message in the queue and parse it to a string
109-
// then fills a buffer with the message
110104
buffer.logStringToSend.Write([]byte(StringBuilder(s.nozzleQueue.Pop())))
111105
buffer.logEventsInCurrentBuffer++
112106

113107
}
114108

115109
func (s *SumoLogicAppender) SendToSumo(buffer *SumoBuffer) {
116110
buffer.channelMessage <- "Buffer being sent"
117-
fmt.Println(buffer.logStringToSend.String())
118-
fmt.Println("......................")
119111

120112
logging.Trace.Println("Sending logs to Sumologic...")
121113
request, err := http.NewRequest("POST", s.url, buffer.logStringToSend)

0 commit comments

Comments
 (0)