The default backend was printing the date and time before the message
The default backend was printing the date and time before the message.
This means that the default formatter was printing the date instead of just the message as documented, and setting a custom format for the default log would have the time prepended to the message.
For example, this code:
package main
import (
"github.com/op/go-logging"
//"github.com/jeffwilliams/go-logging"
)
func main() {
var format = logging.MustStringFormatter(
"%{color}%{time:15:04:05.000000} %{shortfunc} \u25b6 %{level:.4s} %{id:03x}%{color:reset} %{message}",
)
logging.SetFormatter(format)
var log = logging.MustGetLogger("sandbox")
log.Debug("msg")
log.Info("msg")
log.Warning("msg")
}
Outputs these logs:
2014/12/03 13:34:30 13:34:30.511036 main \u25b6 DEBU 001 msg
2014/12/03 13:34:30 13:34:30.511092 main \u25b6 INFO 002 msg
2014/12/03 13:34:30 13:34:30.511121 main \u25b6 WARN 003 msg
I agree that it would make life easier to get rid of all the flags passed to the log module. But, I'd prefer to define a nicer default than only the message.
Hmm, you're probably right. I've changed it so the default is now the date, time and the message. How does that look?
Looks like that broke a bunch of tests. Let me look into it.
Unit tests fixed.
Sorry for the delay. Will need to think about this since this change breaks backwards compatibility.
No problems! Let me know if you need anything from my side.
On Tue, Nov 24, 2015 at 4:58 PM, Örjan Persson [email protected] wrote:
Sorry for the delay. Will need to think about this since this change breaks backwards compatibility.
— Reply to this email directly or view it on GitHub https://github.com/op/go-logging/pull/39#issuecomment-159417612.