Trying out a version that uses golog
as well as touching up the Makefiles to set SHELL
This commit is contained in:
parent
7ef177a38e
commit
38327558d6
1
logstash/.gitignore
vendored
1
logstash/.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
/agent/lib/
|
/agent/lib/
|
||||||
/crispy/crispy
|
/crispy/crispy
|
||||||
|
/sirgoldenvoncrispywhite/sirgoldenvoncrispywhite
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
|
SHELL := /bin/bash
|
||||||
|
|
||||||
run-crispy: crispy/crispy
|
run-crispy: crispy/crispy
|
||||||
$^
|
$^
|
||||||
|
|
||||||
|
run-sirgoldenvoncrispywhite: sirgoldenvoncrispywhite/sirgoldenvoncrispywhite
|
||||||
|
$^
|
||||||
|
|
||||||
crispy/crispy: crispy/main.go
|
crispy/crispy: crispy/main.go
|
||||||
pushd crispy && go build -v -x . ; popd
|
pushd crispy && go build -v -x . ; popd
|
||||||
|
|
||||||
.PHONY: run-crispy
|
sirgoldenvoncrispywhite/sirgoldenvoncrispywhite: sirgoldenvoncrispywhite/main.go
|
||||||
|
pushd sirgoldenvoncrispywhite && go build -v -x . ; popd
|
||||||
|
|
||||||
|
.PHONY: run-crispy run-sirgoldenvoncrispywhite
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
|
SHELL := /bin/bash
|
||||||
LOGSTASH_VERSION ?= 1.1.13
|
LOGSTASH_VERSION ?= 1.1.13
|
||||||
|
|
||||||
all: lib/logstash.jar
|
all: lib/logstash-$(LOGSTASH_VERSION)-flatjar.jar
|
||||||
|
|
||||||
|
|
||||||
lib/logstash.jar: lib/logstash-$(LOGSTASH_VERSION)-flatjar.jar
|
|
||||||
pushd lib && ln -sv $(notdir $^) $(notdir $@) ; popd
|
|
||||||
|
|
||||||
|
|
||||||
lib/logstash-$(LOGSTASH_VERSION)-flatjar.jar: lib
|
lib/logstash-$(LOGSTASH_VERSION)-flatjar.jar: lib
|
||||||
pushd lib && \
|
pushd lib && \
|
||||||
@ -16,4 +12,4 @@ lib:
|
|||||||
mkdir -p $@
|
mkdir -p $@
|
||||||
|
|
||||||
run-agent: all
|
run-agent: all
|
||||||
java -jar lib/logstash.jar agent -f agent.conf
|
java -jar lib/logstash-$(LOGSTASH_VERSION)-flatjar.jar agent -f agent.conf
|
||||||
|
52
logstash/sirgoldenvoncrispywhite/main.go
Normal file
52
logstash/sirgoldenvoncrispywhite/main.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/modcloth-labs/golog"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
server, err := newCrispyServer()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
http.Handle("/", server)
|
||||||
|
log.Printf("Serving on :9764 with %+v\n", server)
|
||||||
|
log.Fatal(http.ListenAndServe(":9764", nil))
|
||||||
|
}
|
||||||
|
|
||||||
|
type crispyServer struct {
|
||||||
|
logstasher *golog.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCrispyServer() (*crispyServer, error) {
|
||||||
|
logstasher, err := newLogstashLogger()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &crispyServer{logstasher: logstasher}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (me *crispyServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
|
j, err := json.Marshal(r)
|
||||||
|
if err == nil {
|
||||||
|
if me.logstasher != nil {
|
||||||
|
me.logstasher.Infof("%s", string(j))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newLogstashLogger() (*golog.Logger, error) {
|
||||||
|
logger := golog.NewLogger("")
|
||||||
|
tcpProcessor, err := golog.NewTcpProcessorAt(":55784", golog.LOG_DEBUG)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.AddProcessor("tcp", tcpProcessor)
|
||||||
|
return logger, nil
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user