Skip to content

Commit

Permalink
Ignore package from linter and add log example
Browse files Browse the repository at this point in the history
  • Loading branch information
LinMAD committed Mar 8, 2024
1 parent 4cec3b6 commit bb2d0ba
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions adapter/kratos/log.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package logs
package logs //nolint:all

import (
"github.com/coopnorge/go-logger"
Expand All @@ -8,14 +8,13 @@ import (
// Ensure LoggerKratosAdapter implements the log.Logger interface.
var _ log.Logger = (*LoggerKratosAdapter)(nil)

// LoggerKratosAdapter Adapter for Go-Kratos.
// LoggerKratosAdapter adapter for Go-Kratos.
type LoggerKratosAdapter struct {
log *logger.Logger

Check failure on line 13 in adapter/kratos/log.go

View workflow job for this annotation

GitHub Actions / Go 1.21 - validate

undefined: logger (typecheck)
}

// NewLoggerKratosAdapter Coop logger adapter for Go-Kratos.
// NewLoggerKratosAdapter constructor that accepting Coop logger adapter for Go-Kratos.
//
// nolint:typecheck // false positive because of godoc example
// Example:
//
// package main
Expand All @@ -26,7 +25,7 @@ type LoggerKratosAdapter struct {
// )
//
// func main() {
// // Create a Coop logger
// // Create a Coop logger.
// logger.ConfigureGlobalLogger(logger.WithLevel(logger.LevelDebug), logger.WithHook(tracelogger.NewHook()))
//
// // Create a LoggerKratosAdapter and pass it to Go-Kratos so it will know what adapter of logger to use.
Expand All @@ -37,6 +36,12 @@ func NewLoggerKratosAdapter(coopLog *logger.Logger) *LoggerKratosAdapter {
}

// Log prints the keyValPairs to the log.
//
// Example of logs:
//
// {"file":"/project/internal/pkg/logs/kratos.go:36","function":"xxx","level":"debug","msg":"msgconfig loaded: MY_ENV format: ","time":"2000-03-08T10:49:12Z"}
//
// {"file":"/project/internal/pkg/logs/kratos.go:34","function":"xxx","level":"info","msg":"I'm godoc example message","time":"2000-03-08T10:49:12Z"}
func (l *LoggerKratosAdapter) Log(level log.Level, keyValPairs ...interface{}) error {
if len(keyValPairs) == 0 {
return nil
Expand Down

0 comments on commit bb2d0ba

Please sign in to comment.