@@ -4,10 +4,12 @@ import (
44 "fmt"
55 "log"
66 "os"
7+
78 "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/caching"
89 "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/eventRouting"
910 "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/firehoseclient"
1011 "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/logging"
12+ "bitbucket.org/mcplusa-ondemand/firehouse-to-sumologic/sumoCFFirehose"
1113 "github.com/cloudfoundry-community/go-cfclient"
1214 "github.com/pkg/profile"
1315 "gopkg.in/alecthomas/kingpin.v2"
1719 debug = kingpin .Flag ("debug" , "Enable debug mode. This disables forwarding to syslog" ).Default ("false" ).OverrideDefaultFromEnvar ("DEBUG" ).Bool ()
1820 apiEndpoint = "https://api.bosh-lite.com" //kingpin.Flag("api-endpoint", "Api endpoint address. For bosh-lite installation of CF: https://api.10.244.0.34.xip.io").OverrideDefaultFromEnvar("API_ENDPOINT").Required().String()
1921 dopplerEndpoint = kingpin .Flag ("doppler-endpoint" , "Overwrite default doppler endpoint return by /v2/info" ).OverrideDefaultFromEnvar ("DOPPLER_ENDPOINT" ).String ()
20- syslogServer = "192.168.33.10:514" //kingpin.Flag("syslog-server", "Syslog server.").OverrideDefaultFromEnvar("SYSLOG_ENDPOINT").String()
21- syslogProtocol = "udp" //kingpin.Flag("syslog-protocol", "Syslog protocol (tcp/udp).").Default("tcp").OverrideDefaultFromEnvar("SYSLOG_PROTOCOL").String()
22+ syslogServer = "192.168.33.10:514" //kingpin.Flag("syslog-server", "Syslog server.").OverrideDefaultFromEnvar("SYSLOG_ENDPOINT").String()
23+ syslogProtocol = "udp" //kingpin.Flag("syslog-protocol", "Syslog protocol (tcp/udp).").Default("tcp").OverrideDefaultFromEnvar("SYSLOG_PROTOCOL").String()
2224 subscriptionId = kingpin .Flag ("subscription-id" , "Id for the subscription." ).Default ("firehose" ).OverrideDefaultFromEnvar ("FIREHOSE_SUBSCRIPTION_ID" ).String ()
2325 user = kingpin .Flag ("user" , "Admin user." ).Default ("admin" ).OverrideDefaultFromEnvar ("FIREHOSE_USER" ).String ()
2426 password = kingpin .Flag ("password" , "Admin password." ).Default ("admin" ).OverrideDefaultFromEnvar ("FIREHOSE_PASSWORD" ).String ()
@@ -43,14 +45,12 @@ func main() {
4345 kingpin .Version (version )
4446 kingpin .Parse ()
4547
46- //Setup Logging
48+ //Setup Logging <-- this loggingClient has to be removed when sumoLog4go Library is working
4749 loggingClient := logging .NewLogging (syslogServer , syslogProtocol , * logFormatterType , * debug )
48- //loggingClient, err := syslog.Dial(syslogProtocol, syslogServer, syslog.LOG_ERR, "demotag")
49- //defer loggingClient.Close()
50- //if err != nil {
51- // log.Fatal("error")
52- //}
53- logging .LogStd (fmt .Sprintf ("Starting firehose-to-syslog %s " , version ), true )
50+ //Setup Loggin with sumoLog4go library
51+ loggingClientSumo := sumoCFFirehose .NewSumoLogicAppender ("http://httpbin.org/post" , 1000 )
52+
53+ logging .LogStd (fmt .Sprintf ("Starting firehose-to-sumo %s " , version ), true )
5454
5555 if * modeProf != "" {
5656 switch * modeProf {
@@ -77,12 +77,6 @@ func main() {
7777 cfClient .Endpoint .DopplerEndpoint = * dopplerEndpoint
7878 }
7979
80- logging .LogStd (fmt .Sprintf ("Login with '%s' user" , * user ), true )
81- logging .LogStd (fmt .Sprintf ("using '%s' as user" , c .Username ), true )
82- logging .LogStd (fmt .Sprintf ("using '%s' as password" , * password ), true )
83-
84- logging .LogStd (fmt .Sprintf ("Using %s as doppler endpoint" , cfClient .Endpoint .DopplerEndpoint ), true )
85-
8680 //Creating Caching
8781 var cachingClient caching.Caching
8882 if caching .IsNeeded (* wantedEvents ) {
@@ -91,7 +85,7 @@ func main() {
9185 cachingClient = caching .NewCachingEmpty ()
9286 }
9387 //Creating Events
94- events := eventRouting .NewEventRouting (cachingClient , loggingClient )
88+ events := eventRouting .NewEventRouting (cachingClient , loggingClient , loggingClientSumo )
9589 err := events .SetupEventRouting (* wantedEvents )
9690 if err != nil {
9791 log .Fatal ("Error setting up event routing: " , err )
@@ -124,12 +118,10 @@ func main() {
124118 IdleTimeoutSeconds : * keepAlive ,
125119 FirehoseSubscriptionID : * subscriptionId ,
126120 }
127- logging .LogStd (fmt .Sprintf ("connect logging '%s'" ,loggingClient .Connect ()), true )
128- logging .LogStd (fmt .Sprintf ("using '%s' as syslogServer" , syslogServer ), true )
129- logging .LogStd (fmt .Sprintf ("using '%s' as syslogServer" , * debug ), true )
130- if loggingClient .Connect () || * debug {
131121
132- logging .LogStd ("Connected to Syslog Server! Connecting to Firehose..." , true )
122+ if /*loggingClientSumo.Connect() ||*/ * debug {
123+
124+ logging .LogStd ("Connected to Server! Connecting to Firehose..." , true )
133125 firehoseClient := firehoseclient .NewFirehoseNozzle (cfClient , events , firehoseConfig )
134126 err = firehoseClient .Start ()
135127 if err != nil {
0 commit comments