1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-14 01:35:23 +08:00

loggers: set level

This commit is contained in:
Juan Batiz-Benet
2014-10-04 03:53:21 -07:00
parent 7e1cd59259
commit 0c8ae7674e
12 changed files with 21 additions and 26 deletions

View File

@ -107,6 +107,8 @@ func DOut(format string, a ...interface{}) {
}
}
var loggers = []string{}
// SetupLogging will initialize the logger backend and set the flags.
func SetupLogging() {
backend := logging.NewLogBackend(os.Stderr, "", 0)
@ -119,12 +121,17 @@ func SetupLogging() {
}
*/
logging.SetFormatter(logging.MustStringFormatter(LogFormat))
for _, n := range loggers {
logging.SetLevel(logging.ERROR, n)
}
}
// Logger retrieves a particular logger + initializes it at a particular level
func Logger(name string, lvl logging.Level) *logging.Logger {
func Logger(name string) *logging.Logger {
log := logging.MustGetLogger(name)
logging.SetLevel(lvl, name)
// logging.SetLevel(lvl, name) // can't set level here.
loggers = append(loggers, name)
return log
}