Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
defaultGenericLogger supports debug flag
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Rodriguez <jrodriguez@pivotallabs.com>
  • Loading branch information
Johannes Petzold committed Aug 12, 2014
1 parent 901c746 commit 7e6ea91
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion appservice/app_service_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package appservice_test

import (
. "github.com/cloudfoundry/loggregatorlib/appservice"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/loggregatorlib/appservice"
)

var _ = Describe("AppService", func() {
Expand Down
23 changes: 14 additions & 9 deletions cfcomponent/generic_logger/generic_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,28 @@ type GenericLogger interface {
Fatalf(string, ...interface{})
Errorf(string, ...interface{})
Debugf(string, ...interface{})

}

type defaultGenericLogger struct{}
type defaultGenericLogger struct {
debug bool
}

func NewDefaultGenericLogger() GenericLogger {
return defaultGenericLogger{}
func NewDefaultGenericLogger(debug bool) GenericLogger {
return defaultGenericLogger{
debug: debug,
}
}

func (defaultGenericLogger) Fatalf(format string, args... interface{}) {
func (defaultGenericLogger) Fatalf(format string, args ...interface{}) {
log.Fatalf(format, args...)
}

func (defaultGenericLogger) Errorf(format string, args... interface{}) {
log.Printf("ERROR: " + format, args...)
func (defaultGenericLogger) Errorf(format string, args ...interface{}) {
log.Printf("ERROR: "+format, args...)
}

func (defaultGenericLogger) Debugf(format string, args... interface{}) {
log.Printf("DEBUG: " + format, args...)
func (l defaultGenericLogger) Debugf(format string, args ...interface{}) {
if l.debug {
log.Printf("DEBUG: "+format, args...)
}
}
2 changes: 1 addition & 1 deletion loggregatorclient/loggregator_client.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package loggregatorclient

import (
"github.com/cloudfoundry/loggregatorlib/cfcomponent/instrumentation"
"github.com/cloudfoundry/loggregatorlib/cfcomponent/generic_logger"
"github.com/cloudfoundry/loggregatorlib/cfcomponent/instrumentation"
"net"
"sync/atomic"
)
Expand Down
2 changes: 1 addition & 1 deletion store/cache/app_service_cache_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package cache_test

import (
. "github.com/cloudfoundry/loggregatorlib/store/cache"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/loggregatorlib/store/cache"

"github.com/cloudfoundry/loggregatorlib/appservice"
)
Expand Down

0 comments on commit 7e6ea91

Please sign in to comment.