logging: Enable logging across storage fs layer. (#1367)

Adds log.Debugf at all the layer - fixes #1074
This commit is contained in:
Harshavardhana
2016-04-24 00:36:00 -07:00
committed by Anand Babu (AB) Periasamy
parent d63d17012d
commit e9fba04b36
8 changed files with 287 additions and 39 deletions
+12 -3
View File
@@ -34,15 +34,24 @@ type localFile struct {
*os.File
}
func enableFileLogger(filename string) {
file, e := os.OpenFile(filename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
func enableFileLogger() {
flogger := serverConfig.GetFileLogger()
if !flogger.Enable || flogger.Filename != "" {
return
}
file, e := os.OpenFile(flogger.Filename, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
fatalIf(probe.NewError(e), "Unable to open log file.", nil)
// Add a local file hook.
log.Hooks.Add(&localFile{file})
lvl, e := logrus.ParseLevel(flogger.Level)
fatalIf(probe.NewError(e), "Unknown log level detected, please fix your console logger configuration.", nil)
// Set default JSON formatter.
log.Formatter = new(logrus.JSONFormatter)
log.Level = logrus.InfoLevel // Minimum log level.
log.Level = lvl // Minimum log level.
}
// Fire fires the file logger hook and logs to the file.