Reviewed-on: #14 Co-authored-by: andrey <andrey@4devs.io> Co-committed-by: andrey <andrey@4devs.io>
This commit was merged in pull request #14.
This commit is contained in:
@@ -2,24 +2,25 @@ 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))
|
||||
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:13
|
||||
// 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(1))
|
||||
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":22,"func":"log_test.ExampleWithSource_json"}}
|
||||
// {"msg":"debug message","source":{"file":"source_example_test.go","line":23,"func":"log_test.ExampleWithSource_json"}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user