From af79082b5f6332d3ab1438182b89a0ebe534301f Mon Sep 17 00:00:00 2001 From: Niels Henrik Hagen Date: Sun, 15 Sep 2024 12:44:52 +0200 Subject: [PATCH] docs: Document the Kratos logging adapter --- adapter/kratos/log.go | 1 + docs/index.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/adapter/kratos/log.go b/adapter/kratos/log.go index 0f52f3a..b0fa7b1 100644 --- a/adapter/kratos/log.go +++ b/adapter/kratos/log.go @@ -21,6 +21,7 @@ type LoggerKratosAdapter struct { // // import ( // "github.com/coopnorge/go-logger" +// "github.com/coopnorge/go-logger/adapter/kratos" // "github.com/go-kratos/kratos/v2/log" // ) // diff --git a/docs/index.md b/docs/index.md index 40edba7..e267254 100644 --- a/docs/index.md +++ b/docs/index.md @@ -141,6 +141,25 @@ func main() { } ``` +### Kratos + +To ensure that Kratos outputs logs in the correct format Kratos must be +configured with a custom logger. + +```go + package main + + import ( + "github.com/coopnorge/go-logger" + "github.com/coopnorge/go-logger/adapter/kratos" + "github.com/go-kratos/kratos/v2/log" + ) + + func main() { + log.SetLogger(logs.NewLoggerKratosAdapter(logger.Global())) + } +``` + ## Hooks Hooks are functions that are triggered on all log-entries and allow for data to