You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
657 B
26 lines
657 B
package log_test
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
|
|
"gitoa.ru/go-4devs/log"
|
|
)
|
|
|
|
func ExampleWithSource() {
|
|
ctx := context.Background()
|
|
logger := log.New(log.WithStdout()).With(log.WithSource(1, filepath.Base))
|
|
|
|
logger.Debug(ctx, "debug message")
|
|
// Output:
|
|
// msg="debug message" source=source_example_test.go:14
|
|
}
|
|
|
|
func ExampleWithSource_json() {
|
|
ctx := context.Background()
|
|
logger := log.New(log.WithStdout(), log.WithJSONFormat()).With(log.WithSource(2, filepath.Base))
|
|
|
|
logger.Debug(ctx, "debug message")
|
|
// Output:
|
|
// {"msg":"debug message","source":{"file":"source_example_test.go","line":23,"func":"log_test.ExampleWithSource_json"}}
|
|
}
|
|
|