Skip to content

Commit a1eb015

Browse files
committed
Merged in feature/SCFF-24 (pull request #4)
feature/SCFF-24 removed files related to syslog
2 parents e46c93a + f80d2cb commit a1eb015

12 files changed

Lines changed: 59 additions & 459 deletions

File tree

caching/caching_boltdb.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ package caching
22

33
import (
44
"fmt"
5-
"github.com/boltdb/bolt"
6-
"bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/logging"
7-
cfClient "github.com/cloudfoundry-community/go-cfclient"
8-
json "github.com/mailru/easyjson"
5+
96
"log"
107
"os"
118
"time"
9+
10+
"github.com/boltdb/bolt"
11+
cfClient "github.com/cloudfoundry-community/go-cfclient"
12+
json "github.com/mailru/easyjson"
1213
)
1314

1415
type CachingBolt struct {
@@ -104,12 +105,11 @@ func (c *CachingBolt) GetAppByGuid(appGuid string) []App {
104105

105106
func (c *CachingBolt) GetAllApp() []App {
106107

107-
logging.LogStd("Retrieving Apps for Cache...", false)
108108
var apps []App
109109

110110
defer func() {
111111
if r := recover(); r != nil {
112-
logging.LogError("Recovered in caching.GetAllApp()", r)
112+
//logging.LogError("Recovered in caching.GetAllApp()", r)
113113
}
114114
}()
115115

@@ -119,7 +119,7 @@ func (c *CachingBolt) GetAllApp() []App {
119119
}
120120

121121
for _, app := range cfApps {
122-
logging.LogStd(fmt.Sprintf("App [%s] Found...", app.Name), false)
122+
fmt.Printf("App [%s] Found... \n", app.Name)
123123
apps = append(apps, App{
124124
app.Name,
125125
app.Guid,
@@ -132,7 +132,7 @@ func (c *CachingBolt) GetAllApp() []App {
132132
}
133133

134134
c.fillDatabase(apps)
135-
logging.LogStd(fmt.Sprintf("Found [%d] Apps!", len(apps)), false)
135+
fmt.Printf("Found [%d] Apps!", len(apps))
136136

137137
return apps
138138
}
@@ -142,7 +142,6 @@ func (c *CachingBolt) GetAppInfo(appGuid string) App {
142142
var d []byte
143143
var app App
144144
c.Appdb.View(func(tx *bolt.Tx) error {
145-
logging.LogStd(fmt.Sprintf("Looking for App %s in Cache!\n", appGuid), false)
146145
b := tx.Bucket([]byte("AppBucket"))
147146
d = b.Get([]byte(appGuid))
148147
return nil

eventRouting/eventRouting_test.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package eventRouting_test
33
import (
44
. "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/caching/cachingfakes"
55
. "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/eventRouting"
6-
. "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/logging/loggingfakes"
76
. "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/sumoCFFirehose/sumoLog4gofakes" //**
87
. "github.com/cloudfoundry/sonde-go/events"
98
. "github.com/onsi/ginkgo"
@@ -15,10 +14,10 @@ var _ = Describe("Events", func() {
1514
var eventRouting *EventRouting
1615

1716
BeforeEach(func() {
18-
logging := new(FakeLogging)
17+
//*logging := new(FakeLogging)
1918
caching := new(FakeCaching)
2019
sLAppender := new(FakeSumoLog4go)
21-
eventRouting = NewEventRouting(caching, logging, sLAppender)
20+
eventRouting = NewEventRouting(caching, sLAppender)
2221
eventRouting.SetupEventRouting("")
2322

2423
})
@@ -61,13 +60,6 @@ var _ = Describe("Events", func() {
6160
})
6261
})
6362

64-
Context("called with extrafield", func() {
65-
It("Shoud return correct extrafields", func() {
66-
eventRouting.SetExtraFields("dev:env")
67-
Expect(eventRouting.ExtraFields).To(Equal(map[string]string{"dev": "env"}))
68-
})
69-
})
70-
7163
Context("GetListAuthorizedEventEvents", func() {
7264
It("should return right list of authorized events", func() {
7365
Expect(GetListAuthorizedEventEvents()).To(Equal("ContainerMetric, CounterEvent, Error, HttpStart, HttpStartStop, HttpStop, LogMessage, ValueMetric"))

eventRouting/eventrouting.go

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ package eventRouting
22

33
import (
44
"fmt"
5-
"os"
65
"sort"
76
"strings"
87
"sync"
98
"time"
109

1110
"bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/caching"
1211
fevents "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/events"
13-
"bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/extrafields"
14-
"bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/logging"
15-
"bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/sumoCFFirehose" //**
12+
"bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/sumoCFFirehose"
1613
"github.com/Sirupsen/logrus"
1714
"github.com/cloudfoundry/sonde-go/events"
1815
)
@@ -23,19 +20,17 @@ type EventRouting struct {
2320
selectedEventsCount map[string]uint64
2421
mutex *sync.Mutex
2522
sLAppender sumoCFFirehose.SumoCFFirehose //**
26-
log logging.Logging
27-
ExtraFields map[string]string
23+
//*log logging.Logging
2824
}
2925

30-
func NewEventRouting(caching caching.Caching, logging logging.Logging, sLAppender sumoCFFirehose.SumoCFFirehose) *EventRouting {
26+
func NewEventRouting(caching caching.Caching, sLAppender sumoCFFirehose.SumoCFFirehose) *EventRouting {
3127
return &EventRouting{
3228
CachingClient: caching,
3329
selectedEvents: make(map[string]bool),
3430
selectedEventsCount: make(map[string]uint64),
3531
sLAppender: sLAppender, //**
36-
log: logging,
37-
mutex: &sync.Mutex{},
38-
ExtraFields: make(map[string]string),
32+
//* log: logging,
33+
mutex: &sync.Mutex{},
3934
}
4035
}
4136

@@ -70,7 +65,6 @@ func (e *EventRouting) RouteEvent(msg *events.Envelope) {
7065

7166
event.AnnotateWithEnveloppeData(msg)
7267

73-
event.AnnotateWithMetaData(e.ExtraFields)
7468
if _, hasAppId := event.Fields["cf_app_id"]; hasAppId {
7569
event.AnnotateWithAppData(e.CachingClient)
7670
}
@@ -80,8 +74,10 @@ func (e *EventRouting) RouteEvent(msg *events.Envelope) {
8074
if ignored, hasIgnoredField := event.Fields["cf_ignored_app"]; ignored == true && hasIgnoredField {
8175
e.selectedEventsCount["ignored_app_message"]++
8276
} else {
83-
e.sLAppender.AppendLogs(event.Fields) //**
84-
e.log.ShipEvents(event.Fields, event.Msg) // here we have to change the method for the one on sumoLogicAppender
77+
/*fmt.Printf("I'm in eventRpouting method .. -------")
78+
fmt.Println(event.Fields)
79+
fmt.Println(event.Msg)*/
80+
e.sLAppender.AppendLogs(event.Fields) //**/here we have to change the method for the one on sumoLogicAppender
8581
e.selectedEventsCount[eventType.String()]++
8682

8783
}
@@ -97,7 +93,7 @@ func (e *EventRouting) SetupEventRouting(wantedEvents string) error {
9793
for _, event := range strings.Split(wantedEvents, ",") {
9894
if e.isAuthorizedEvent(strings.TrimSpace(event)) {
9995
e.selectedEvents[strings.TrimSpace(event)] = true
100-
logging.LogStd(fmt.Sprintf("Event Type [%s] is included in the fireshose!", event), false)
96+
//logging.LogStd(fmt.Sprintf("Event Type [%s] is included in the fireshose!", event), false)
10197
} else {
10298
return fmt.Errorf("Rejected Event Name [%s] - Valid events: %s", event, GetListAuthorizedEventEvents())
10399
}
@@ -106,16 +102,6 @@ func (e *EventRouting) SetupEventRouting(wantedEvents string) error {
106102
return nil
107103
}
108104

109-
func (e *EventRouting) SetExtraFields(extraEventsString string) {
110-
// Parse extra fields from cmd call
111-
extraFields, err := extrafields.ParseExtraFields(extraEventsString)
112-
if err != nil {
113-
logging.LogError("Error parsing extra fields: ", err)
114-
os.Exit(1)
115-
}
116-
e.ExtraFields = extraFields
117-
}
118-
119105
func (e *EventRouting) isAuthorizedEvent(wantedEvent string) bool {
120106
for _, authorizeEvent := range events.Envelope_EventType_name {
121107
if wantedEvent == authorizeEvent {
@@ -159,7 +145,8 @@ func (e *EventRouting) LogEventTotals(logTotalsTime time.Duration) {
159145
startTime = time.Now()
160146
event, lastCount := e.getEventTotals(totalElapsedTime, elapsedTime, count)
161147
count = lastCount
162-
e.log.ShipEvents(event.Fields, event.Msg)
148+
//*e.log.ShipEvents(event.Fields, event.Msg)
149+
e.sLAppender.AppendLogs(event.Fields)
163150
}
164151
}()
165152
}

extrafields/extrafields.go

Lines changed: 0 additions & 36 deletions
This file was deleted.

extrafields/extrafields_suite_test.go

Lines changed: 0 additions & 67 deletions
This file was deleted.

firehoseclient/firehoseclient.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import (
55
"time"
66

77
"bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/eventRouting"
8-
"bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/logging"
8+
//*"bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/logging"
9+
910
"github.com/cloudfoundry-community/go-cfclient"
1011
"github.com/cloudfoundry/noaa/consumer"
1112
"github.com/cloudfoundry/sonde-go/events"
@@ -75,22 +76,22 @@ func (f *FirehoseNozzle) handleError(err error) {
7576

7677
switch {
7778
case websocket.IsCloseError(err, websocket.CloseNormalClosure):
78-
logging.LogError("Normal Websocket Closure", err)
79+
//logging.LogError("Normal Websocket Closure", err)
7980
case websocket.IsCloseError(err, websocket.ClosePolicyViolation):
80-
logging.LogError("Error while reading from the firehose", err)
81-
logging.LogError("Disconnected because nozzle couldn't keep up. Please try scaling up the nozzle.", nil)
81+
//logging.LogError("Error while reading from the firehose", err)
82+
//logging.LogError("Disconnected because nozzle couldn't keep up. Please try scaling up the nozzle.", nil)
8283

8384
default:
84-
logging.LogError("Error while reading from the firehose", err)
85+
//logging.LogError("Error while reading from the firehose", err)
8586
}
8687

87-
logging.LogError("Closing connection with traffic controller due to error", err)
88+
//logging.LogError("Closing connection with traffic controller due to error", err)
8889
f.consumer.Close()
8990
}
9091

9192
func (f *FirehoseNozzle) handleMessage(envelope *events.Envelope) {
9293
if envelope.GetEventType() == events.Envelope_CounterEvent && envelope.CounterEvent.GetName() == "TruncatingBuffer.DroppedMessages" && envelope.GetOrigin() == "doppler" {
93-
logging.LogStd("We've intercepted an upstream message which indicates that the nozzle or the TrafficController is not keeping up. Please try scaling up the nozzle.", true)
94+
//logging.LogStd("We've intercepted an upstream message which indicates that the nozzle or the TrafficController is not keeping up. Please try scaling up the nozzle.", true)
9495
}
9596
}
9697

logging/logging.go

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)