-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: SungJin1212 <[email protected]>
- Loading branch information
1 parent
7191ecb
commit 39a284b
Showing
45 changed files
with
5,477 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package log | ||
|
||
import ( | ||
"log/slog" | ||
|
||
"github.com/go-kit/log" | ||
sloggk "github.com/tjhop/slog-gokit" | ||
) | ||
|
||
// GoKitLogToSlog convert go-kit/log to slog | ||
// usage: util_log.GoKitLogToSlog(gokitLogger) | ||
func GoKitLogToSlog(logger log.Logger) *slog.Logger { | ||
levelVar := slog.LevelVar{} | ||
promLogger, ok := logger.(*PrometheusLogger) | ||
if !ok { | ||
levelVar.Set(slog.LevelDebug) | ||
} else { | ||
switch promLogger.lv.String() { | ||
case "debug": | ||
levelVar.Set(slog.LevelDebug) | ||
case "info": | ||
levelVar.Set(slog.LevelInfo) | ||
case "warn": | ||
levelVar.Set(slog.LevelWarn) | ||
case "error": | ||
levelVar.Set(slog.LevelError) | ||
} | ||
} | ||
return slog.New(sloggk.NewGoKitHandler(logger, &levelVar)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package log | ||
|
||
import ( | ||
"context" | ||
"log/slog" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/weaveworks/common/server" | ||
) | ||
|
||
func Test_SlogAdapter_LogLevel(t *testing.T) { | ||
ctx := context.Background() | ||
logLevels := []string{"debug", "info", "warn", "error"} | ||
slogLevels := []slog.Level{slog.LevelDebug, slog.LevelInfo, slog.LevelWarn, slog.LevelError} | ||
|
||
for i, lv := range logLevels { | ||
cfg := &server.Config{} | ||
require.NoError(t, cfg.LogLevel.Set(lv)) | ||
InitLogger(cfg) | ||
|
||
slog := GoKitLogToSlog(Logger) | ||
for j, slogLv := range slogLevels { | ||
if i <= j { | ||
t.Logf("[go-kit log level: %v, slog level: %v] slog should be enabled", lv, slogLv) | ||
require.True(t, slog.Enabled(ctx, slogLv)) | ||
} else { | ||
t.Logf("[go-kit log level: %v, slog level: %v] slog should be disabled", lv, slogLv) | ||
require.False(t, slog.Enabled(ctx, slogLv)) | ||
} | ||
} | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
vendor/cloud.google.com/go/auth/internal/compute/compute.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
vendor/cloud.google.com/go/auth/internal/compute/manufacturer.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
vendor/cloud.google.com/go/auth/internal/compute/manufacturer_linux.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
vendor/cloud.google.com/go/auth/internal/compute/manufacturer_windows.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.