Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The default backend was printing the date and time before the message #39

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jeffwilliams
Copy link

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

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.
@op
Copy link
Owner

op commented Dec 8, 2014

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.

@jeffwilliams
Copy link
Author

Hmm, you're probably right. I've changed it so the default is now the date, time and the message. How does that look?

@jeffwilliams
Copy link
Author

Looks like that broke a bunch of tests. Let me look into it.

@jeffwilliams
Copy link
Author

Unit tests fixed.

@op
Copy link
Owner

op commented Nov 24, 2015

Sorry for the delay. Will need to think about this since this change breaks backwards compatibility.

@jeffwilliams
Copy link
Author

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
#39 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants