diff options
author | Aleksey Myasnikov <79263256394@ya.ru> | 2022-02-18 12:46:31 +0300 |
---|---|---|
committer | Aleksey Myasnikov <79263256394@ya.ru> | 2022-02-18 12:46:31 +0300 |
commit | f31c1384645cf16a5f4f092c4bc6535249e2b23c (patch) | |
tree | c18c1421ff4d290980f4d10e86404e38c851f975 | |
parent | b658dedfbf7b6b0262f0113b4f717ebc90b82a11 (diff) | |
download | ydb-f31c1384645cf16a5f4f092c4bc6535249e2b23c.tar.gz |
fix go logging
fix go logging
ref:4fea2cded22a73a9042048655dc385c3d4ff7800
-rw-r--r-- | ydb/docs/ru/core/reference/ydb-sdk/recipes/debug/_includes/logs/go.md | 52 |
1 files changed, 39 insertions, 13 deletions
diff --git a/ydb/docs/ru/core/reference/ydb-sdk/recipes/debug/_includes/logs/go.md b/ydb/docs/ru/core/reference/ydb-sdk/recipes/debug/_includes/logs/go.md index c69f919dd7..c3b39bbbd4 100644 --- a/ydb/docs/ru/core/reference/ydb-sdk/recipes/debug/_includes/logs/go.md +++ b/ydb/docs/ru/core/reference/ydb-sdk/recipes/debug/_includes/logs/go.md @@ -22,14 +22,10 @@ db, err := ydb.New( ctx, ... - ydb.WithTraceDriver(ydbZap.Driver( + ydbZap.WithTraces( log, - trace.DetailsAll, - )), - ydb.WithTraceTable(ydbZap.Table( - log, - trace.DetailsAll, - )), + ydbZap.WithDetails(trace.DetailsAll), + ), ) if err != nil { panic(err) @@ -62,14 +58,44 @@ db, err := ydb.New( ctx, ydb.WithConnectionString(os.Getenv("YDB_CONNECTION_STRING")), - ydb.WithTraceDriver(ydbZerolog.Driver( - log, - trace.DetailsAll, - )), - ydb.WithTraceTable(ydbZerolog.Table( + ydbZerolog.WithTraces( log, + ydbZerolog.WithDetails(trace.DetailsAll), + ), + ) + if err != nil { + panic(err) + } + defer func() { + _ = db.Close(ctx) + }() + } + ``` + {% endcut %} +* {% cut "Подключить собственную имплементацию логгера `github.com/ydb-platform/ydb-go-sdk/v3/log.Logger`" %} + ```go + package main + + import ( + "context" + "os" + + "github.com/ydb-platform/ydb-go-sdk/v3" + "github.com/ydb-platform/ydb-go-sdk/v3/log" + "github.com/ydb-platform/ydb-go-sdk/v3/trace" + ) + + func main() { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + var logger log.Logger // logger implementation with init out of this scope + db, err := ydb.New( + ctx, + ydb.WithConnectionString(os.Getenv("YDB_CONNECTION_STRING")), + ydb.WithLogger( trace.DetailsAll, - )), + ydb.WithExternalLogger(logger), + ), ) if err != nil { panic(err) |