|
@ -52,13 +52,16 @@ func ExampleNew_debugKV() { |
|
|
|
|
|
|
|
|
func ExampleNew_level() { |
|
|
func ExampleNew_level() { |
|
|
logger := log.New(log.WithStdout()).With(log.WithLevel("level", level.Error)) |
|
|
logger := log.New(log.WithStdout()).With(log.WithLevel("level", level.Error)) |
|
|
logger.Info(ctx, "same message") |
|
|
|
|
|
// Output:
|
|
|
|
|
|
|
|
|
|
|
|
logger.Err(ctx, "same error message") |
|
|
logger.Err(ctx, "same error message") |
|
|
// Output: msg="same error message" level=error
|
|
|
// Output: msg="same error message" level=error
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func ExampleNew_level_info() { |
|
|
|
|
|
logger := log.New(log.WithStdout()).With(log.WithLevel("level", level.Error)) |
|
|
|
|
|
logger.Info(ctx, "same message") |
|
|
|
|
|
// Output:
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func ExampleNew_jsonFormat() { |
|
|
func ExampleNew_jsonFormat() { |
|
|
logger := log.New(log.WithStdout(), log.WithJSONFormat()). |
|
|
logger := log.New(log.WithStdout(), log.WithJSONFormat()). |
|
|
With( |
|
|
With( |
|
@ -66,7 +69,7 @@ func ExampleNew_jsonFormat() { |
|
|
log.GoVersion("go-version"), |
|
|
log.GoVersion("go-version"), |
|
|
) |
|
|
) |
|
|
logger.Err(ctx, "same error message") |
|
|
logger.Err(ctx, "same error message") |
|
|
// Output: {"go-version":"go1.17.6","level":"error","msg":"same error message"}
|
|
|
// Output: {"go-version":"go1.17.8","level":"error","msg":"same error message"}
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func ExampleNew_textEncoding() { |
|
|
func ExampleNew_textEncoding() { |
|
@ -79,8 +82,8 @@ func ExampleNew_textEncoding() { |
|
|
logger.InfoKVs(ctx, "same info message", "api-version", 0.1) |
|
|
logger.InfoKVs(ctx, "same info message", "api-version", 0.1) |
|
|
|
|
|
|
|
|
// Output:
|
|
|
// Output:
|
|
|
// msg="same error message" level=error go-version=go1.17.6
|
|
|
// msg="same error message" level=error go-version=go1.17.8
|
|
|
// msg="same info message" api-version=0.1 level=info go-version=go1.17.6
|
|
|
// msg="same info message" api-version=0.1 level=info go-version=go1.17.8
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type ctxKey string |
|
|
type ctxKey string |
|
@ -102,7 +105,7 @@ func ExampleWith() { |
|
|
levelInfo, log.WithContextValue(requestID), log.KeyValue("api", "0.1.0"), log.GoVersion("go"), |
|
|
levelInfo, log.WithContextValue(requestID), log.KeyValue("api", "0.1.0"), log.GoVersion("go"), |
|
|
) |
|
|
) |
|
|
logger.Info(vctx, "same message") |
|
|
logger.Info(vctx, "same message") |
|
|
// Output: msg="same message" level=info requestID=6a5fa048-7181-11ea-bc55-0242ac130003 api=0.1.0 go=go1.17.6
|
|
|
// Output: msg="same message" level=info requestID=6a5fa048-7181-11ea-bc55-0242ac130003 api=0.1.0 go=go1.17.8
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func ExampleLogger_Print() { |
|
|
func ExampleLogger_Print() { |
|
@ -111,7 +114,7 @@ func ExampleLogger_Print() { |
|
|
levelInfo, log.KeyValue("client", "http"), log.KeyValue("api", "0.1.0"), log.GoVersion("go"), |
|
|
levelInfo, log.KeyValue("client", "http"), log.KeyValue("api", "0.1.0"), log.GoVersion("go"), |
|
|
) |
|
|
) |
|
|
logger.Print("same message") |
|
|
logger.Print("same message") |
|
|
// Output: msg="same message" level=info client=http api=0.1.0 go=go1.17.6
|
|
|
// Output: msg="same message" level=info client=http api=0.1.0 go=go1.17.8
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func ExamplePrint() { |
|
|
func ExamplePrint() { |
|
|