@@ -7,21 +7,23 @@ import (
77 "net/http"
88 "time"
99
10- // "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventQueue"
11- . "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/events"
10+ "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/eventQueue"
11+ // "bitbucket.org/mcplusa-ondemand/firehose-to-sumologic/events"
1212)
1313
1414type SumoLogicAppender struct {
1515 url string
1616 connectionTimeout int //10000
1717 httpClient http.Client
18+ nozzleQueue eventQueue.Queue
1819}
1920
20- func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int ) * SumoLogicAppender {
21+ func NewSumoLogicAppender (urlValue string , connectionTimeoutValue int , nozzleQueue eventQueue. Queue ) * SumoLogicAppender {
2122 return & SumoLogicAppender {
2223 url : urlValue ,
2324 connectionTimeout : connectionTimeoutValue ,
2425 httpClient : http.Client {Timeout : time .Duration (connectionTimeoutValue * int (time .Millisecond ))},
26+ nozzleQueue : nozzleQueue ,
2527 }
2628}
2729
@@ -42,7 +44,9 @@ func (s *SumoLogicAppender) Connect() bool {
4244 return success
4345}
4446
45- func (s * SumoLogicAppender ) AppendLogs (event Event ) {
47+ func (s * SumoLogicAppender ) AppendLogs () {
48+ // the appender calls for the next message in the queue and parse it to a string
49+ event := s .nozzleQueue .Pop ().GetNodeEvent ()
4650 /*
4751 if event == nil {
4852 return
@@ -56,7 +60,8 @@ func (s *SumoLogicAppender) AppendLogs(event Event) {
5660 return
5761 }
5862
59- Message := /*strconv.Itoa(fields["timestamp"]) + */ "\t " + event .Fields ["message_type" ].(string ) + "\t " + event .Msg + "\n "
63+ Message := time .Unix (int64 (event .Fields ["timestamp" ].(int64 )), 0 ).String () + "\t " + event .Fields ["message_type" ].(string ) + "\t " + event .Msg + "\n "
64+ fmt .Println (Message )
6065 s .SendToSumo (Message )
6166}
6267
0 commit comments