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

Doc how to convert from logutils #2

Open
josephholsten opened this issue Aug 10, 2017 · 4 comments
Open

Doc how to convert from logutils #2

josephholsten opened this issue Aug 10, 2017 · 4 comments

Comments

@josephholsten
Copy link

josephholsten commented Aug 10, 2017

There are two parts required to migrate from logutils:

  • Initial setup: defining minimum log level to filter, &c. Showing the equivalent of the example from logutils README should be sufficient.
  • Converting message format: all logging calls from [Level] to Level:. Is there a way to to use the messages in logutils format?
@josephholsten
Copy link
Author

Lol. Entering tickets from my phone is the worst.

@d2g
Copy link
Owner

d2g commented Aug 11, 2017

By setting the logger to take the square format it should just work.
logfilter.SetParsers([]logfilter.Parser{logfilter.SqrParser})

Agreed needs to be better documented.

@josephholsten josephholsten changed the title Doc how to conver from logutils Doc how to convert from logutils Aug 12, 2017
@josephholsten
Copy link
Author

how does this look for an updated usage section:

package main

import (
	"fmt"
	"log"

	"github.com/d2g/logfilter"

	"github.com/d2g/logfilter/dummy"
)

func main() {
	// Allow messages at warning and above
	logfilter.Default(logfilter.Warning)
	// Include logs from a package, set a lower level
	logfilter.Include("github.com/d2g/logfilter/dummy").When(logfilter.Info)
	// Exclude logs from a particularly noisy package
	logfilter.Exclude("github.com/d2g/logfilter/noisy")
	// Use "[WARN] " style prefixes, like logutils
	// logfilter.SetParsers([]logfilter.Parser{logfilter.SqrParser})

	// Unformatted log messages
	log.Print("Message I haven't updated") // this will not print
	// With logfilter prefix
	log.Print("Trace: stdlib Tracing")   // this will not print
	log.Print("Debug: stdlib Debugging") // neither will this
	log.Print("Info: stdlib Informing")  // nor this
	log.Print("Warning: stdlib Warning") // this will print
	log.Print("Error: stdlib Erring")    // so will this
	log.Print("Fatal: stdlib Fatality")  // and this

	// Logging from a package
	dummy.Unformatted() // this will not print
	dummy.Trace()       // neither will this
	dummy.Debug()       // nor this
	dummy.Info()        // this will print
	dummy.Warning()     // so will this
	dummy.Error()       // and this
	dummy.Fatal()       // and this
}

Also, any ideas on how to get godoc2md to use a code block like:

```go
...
```

d2g added a commit that referenced this issue Aug 25, 2017
@d2g
Copy link
Owner

d2g commented Aug 25, 2017

Let me know if you think that's enough.

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

No branches or pull requests

2 participants