Skip to content

Commit

Permalink
Add some tracing to see if papertrail gets loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerflint committed Sep 25, 2018
1 parent 44dc7b7 commit ecac403
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
# setup the app dir/working directory
RUN mkdir -p /go/src/github.com/nanopack/logvac
WORKDIR /go/src/github.com/nanopack/logvac

# copy the source
COPY . .

# fetch deps
RUN make deps
8 changes: 7 additions & 1 deletion drain/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func Init() error {
if err != nil {
return fmt.Errorf("Failed to load drains - %s", err)
}
config.Log.Info("3rd-party drains initialized")

return nil
}
Expand Down Expand Up @@ -153,11 +154,13 @@ func publishInit() error {

// InitDrains loads and configures drains from a config file.
func InitDrains() error {
config.Log.Info("loading drains from db")
drainDB, err := NewBoltArchive(filepath.Join(dbDir, "drains.bolt"))
if err != nil {
return fmt.Errorf("Failed to initialize drain db - %s", err)
}
defer drainDB.Close()
config.Log.Info("drains loaded from db")

tDrains := make(map[string]logvac.Drain, 0)
err = drainDB.Get("drainConfig", "drains", &tDrains)
Expand All @@ -169,7 +172,7 @@ func InitDrains() error {
for i := range tDrains {
err := AddDrain(tDrains[i])
if err != nil {
return fmt.Errorf("Failed to load drain 'papertrail' - %s", err)
return fmt.Errorf("Failed to load 3rd-party drain '%s' - %s", i, err)
}
}

Expand All @@ -179,6 +182,8 @@ func InitDrains() error {
// AddDrain starts draining to a third party log service.
func AddDrain(d logvac.Drain) error {

config.Log.Info("Adding drain '%s'", d.Type)

switch d.Type {
case "papertrail":
// if it already exists, close it and create a new one
Expand All @@ -196,6 +201,7 @@ func AddDrain(d logvac.Drain) error {
}
drains["papertrail"] = pTrail
drainCfg["papertrail"] = d
config.Log.Info("3rd-party drain 'papertrail' initialized")
// case "datadog":
// // if it already exists, close it and create a new one
// if _, ok := drains["datadog"]; ok {
Expand Down
7 changes: 5 additions & 2 deletions drain/papertrail.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"net"

"github.com/nanopack/logvac/config"
"github.com/nanopack/logvac/core"
)

Expand All @@ -24,12 +25,14 @@ func NewPapertrailClient(uri string) (*Papertrail, error) {
if err != nil {
return nil, fmt.Errorf("Failed to dial papertrail - %s", err.Error())
}

config.Log.Info("Connection to papertrail endpoint established")

return &Papertrail{conn}, nil
}

// Init initializes a connection to mist
func (p Papertrail) Init() error {
func (p *Papertrail) Init() error {

// add drain
logvac.AddDrain("papertrail", p.Publish)
Expand All @@ -38,7 +41,7 @@ func (p Papertrail) Init() error {
}

// Publish utilizes mist's Publish to "drain" a log message
func (p Papertrail) Publish(msg logvac.Message) {
func (p *Papertrail) Publish(msg logvac.Message) {
p.Conn.Write(msg.Raw)
}

Expand Down

0 comments on commit ecac403

Please sign in to comment.