github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/log/log.go (about)

     1  // Copyright 2011, 2012, 2013 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package log
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/juju/loggo"
    10  )
    11  
    12  var (
    13  	logger = loggo.GetLogger("juju")
    14  )
    15  
    16  // Errorf logs a message using the ERROR priority.
    17  func Errorf(format string, a ...interface{}) error {
    18  	logger.Logf(loggo.ERROR, format, a...)
    19  	return nil
    20  }
    21  
    22  // Warningf logs a message using the WARNING priority.
    23  func Warningf(format string, a ...interface{}) error {
    24  	logger.Logf(loggo.WARNING, format, a...)
    25  	return nil
    26  }
    27  
    28  // Noticef logs a message using the NOTICE priority.
    29  // Notice doesn't really convert to the loggo priorities...
    30  func Noticef(format string, a ...interface{}) error {
    31  	logger.Logf(loggo.INFO, format, a...)
    32  	return nil
    33  }
    34  
    35  // Infof logs a message using the INFO priority.
    36  func Infof(format string, a ...interface{}) error {
    37  	logger.Logf(loggo.INFO, format, a...)
    38  	return nil
    39  }
    40  
    41  // Debugf logs a message using the DEBUG priority.
    42  func Debugf(format string, a ...interface{}) (err error) {
    43  	logger.Logf(loggo.DEBUG, format, a...)
    44  	return nil
    45  }
    46  
    47  // Log the error and return an error with the same text.
    48  func LoggedErrorf(logger loggo.Logger, format string, a ...interface{}) error {
    49  	logger.Logf(loggo.ERROR, format, a...)
    50  	return fmt.Errorf(format, a...)
    51  }