Skip to content

Commit

Permalink
SetLogTrace docs: setting affects to all logging supporting function
Browse files Browse the repository at this point in the history
  • Loading branch information
lainio committed Mar 9, 2024
1 parent 1b8c72d commit ff0f65c
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ func PanicTracer() io.Writer {
return tracer.Panic.Tracer()
}

// LogTracer returns current io.Writer for try.Out().Logf().
// The default value is nil.
// LogTracer returns a current io.Writer for the explicit try.Result.Logf
// function and automatic logging used in err2.Handle and err2.Catch. The
// default value is nil.
func LogTracer() io.Writer {
return tracer.Log.Tracer()
}
Expand All @@ -32,7 +33,7 @@ func LogTracer() io.Writer {
// func CopyFile(src, dst string) (err error) {
// defer err2.Handle(&err) // <- error trace print decision is done here
//
// Remember that you can overwrite these with Flag package support. See
// Remember that you can reset these with Flag package support. See
// documentation of err2 package's flag section.
func SetErrorTracer(w io.Writer) {
tracer.Error.SetTracer(w)
Expand All @@ -45,32 +46,35 @@ func SetErrorTracer(w io.Writer) {
// handler, e.g:
//
// func CopyFile(src, dst string) (err error) {
// defer err2.Handle(&err) // <- error trace print decision is done here
// defer err2.Handle(&err) // <- panic trace print decision is done here
//
// Remember that you can overwrite these with Flag package support. See
// Remember that you can reset these with Flag package support. See
// documentation of err2 package's flag section.
func SetPanicTracer(w io.Writer) {
tracer.Panic.SetTracer(w)
}

// SetLogTracer sets a io.Writer for try.Out().Logf() function. The default is
// nil and then err2 uses std log package for logging.
// SetLogTracer sets a current io.Writer for the explicit try.Result.Logf
// function and automatic logging used in err2.Handle and err2.Catch. The
// default is nil and then err2 uses std log package for logging.
//
// You can use that to redirect packages like glog and have proper logging. For
// glog, add this line at the beginning of your app:
// You can use the std log package to redirect other logging packages like glog
// to automatically work with the err2 package. For the glog, add this line at
// the beginning of your app:
//
// glog.CopyStandardLogTo("INFO")
//
// Remember that you can overwrite these with Flag package support. See
// Remember that you can reset these with Flag package support. See
// documentation of err2 package's flag section.
func SetLogTracer(w io.Writer) {
tracer.Log.SetTracer(w)
}

// SetTracers a convenient helper to set a io.Writer for error and panic stack
// tracing. More information see SetErrorTracer and SetPanicTracer functions.
// SetTracers a helper to set a io.Writer for error and panic stack tracing, the
// log tracer is set as well. More information see SetErrorTracer,
// SetPanicTracer, and SetLogTracer functions.
//
// Remember that you can overwrite these with Flag package support. See
// Remember that you can reset these with Flag package support. See
// documentation of err2 package's flag section.
func SetTracers(w io.Writer) {
tracer.Error.SetTracer(w)
Expand Down

0 comments on commit ff0f65c

Please sign in to comment.