Replace logging calls with new style

This commit is contained in:
Bryan Boreham committed 2015-07-01 12:26:23 +01:00
1 parent c786e7eb5a
commit d82578d895
30 files changed
+212 -237

No files matched your search

+3 -3
View File
@@ -44,7 +44,7 @@ func NewClient(apiPath string) (*Client, error) {
func (c *Client) AddObserver(ob ContainerObserver) error {
events := make(chan *docker.APIEvents)
if err := c.AddEventListener(events); err != nil {
Error.Printf("[docker] Unable to add listener to Docker API: %s", err)
Log.Errorf("[docker] Unable to add listener to Docker API: %s", err)
return err
}
@@ -63,7 +63,7 @@ func (c *Client) AddObserver(ob ContainerObserver) error {
// IsContainerNotRunning returns true if we have checked with Docker that the ID is not running
func (c *Client) IsContainerNotRunning(idStr string) bool {
if !IsContainerID(idStr) {
Debug.Printf("[docker] '%s' does not seem to be a container id", idStr)
Log.Debugf("[docker] '%s' does not seem to be a container id", idStr)
return false
}
@@ -75,6 +75,6 @@ func (c *Client) IsContainerNotRunning(idStr string) bool {
if _, notThere := err.(*docker.NoSuchContainer); notThere {
return true
}
Error.Printf("[docker] Could not check container status: %s", err)
Log.Errorf("[docker] Could not check container status: %s", err)
return false
}
+2 -2
View File
@@ -2,13 +2,13 @@ package common
func CheckFatal(e error) {
if e != nil {
Error.Fatal(e)
Log.Fatal(e)
}
}
func CheckWarn(e error) {
if e != nil {
Warning.Println(e)
Log.Warningln(e)
}
}
+4 -23
View File
@@ -35,11 +35,9 @@ var (
)
var (
Debug *logrus.Logger
Info *logrus.Logger
Warning *logrus.Logger
Error *logrus.Logger
debugF bool
Log *logrus.Logger
Info *logrus.Logger
debugF bool
)
func InitLogging(debugHandle io.Writer,
@@ -47,30 +45,13 @@ func InitLogging(debugHandle io.Writer,
warningHandle io.Writer,
errorHandle io.Writer) {
Debug = &logrus.Logger{
Out: debugHandle,
Formatter: standardTextFormatter,
Hooks: make(logrus.LevelHooks),
Level: logrus.DebugLevel,
}
Info = &logrus.Logger{
Out: infoHandle,
Formatter: standardTextFormatter,
Hooks: make(logrus.LevelHooks),
Level: logrus.InfoLevel,
}
Warning = &logrus.Logger{
Out: warningHandle,
Formatter: standardTextFormatter,
Hooks: make(logrus.LevelHooks),
Level: logrus.WarnLevel,
}
Error = &logrus.Logger{
Out: errorHandle,
Formatter: standardTextFormatter,
Hooks: make(logrus.LevelHooks),
Level: logrus.ErrorLevel,
}
Log = Info
}
func InitDefaultLogging(debug bool) {
+3 -3
View File
@@ -76,7 +76,7 @@ func NewSchedQueue(clock clock.Clock) *SchedQueue {
// Start starts the scheduled queue
func (cq *SchedQueue) Start() {
go func() {
defer func() { Debug.Printf("[sched-q] Quitting (%d calls pending)", len(cq.callablesH)) }()
defer func() { Log.Debugf("[sched-q] Quitting (%d calls pending)", len(cq.callablesH)) }()
var now time.Time
timer := cq.clock.Timer(time.Duration(math.MaxInt64))
@@ -116,14 +116,14 @@ func (cq *SchedQueue) Start() {
// Stop stops the scheduled queue
func (cq *SchedQueue) Stop() {
Debug.Printf("[sched-q] Stopping...")
Log.Debugf("[sched-q] Stopping...")
cq.closeChan <- true
}
// Add schedules a call.
// The callable should not modify the scheduled queue in any way.
func (cq *SchedQueue) Add(c callable, t time.Time) {
Debug.Printf("[sched-q] Adding call at %s", t)
Log.Debugf("[sched-q] Adding call at %s", t)
ce := schedCall{c: c, t: t}
cq.schedChan <- &ce
}