Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
fix: use log-level: error for kics e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <[email protected]>
  • Loading branch information
csatib02 committed Jul 24, 2024
1 parent f0eda70 commit 979ac95
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/log/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func GetLoggerFromContextOrDiscard(ctx context.Context) *log.Entry {
if !ok {
logger = log.NewEntry(&log.Logger{
Out: io.Discard,
Level: 0,
Level: log.PanicLevel,
}).WithContext(ctx)
}
return logger
Expand Down
7 changes: 4 additions & 3 deletions plugins/sdk-go/plugin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,24 @@
package plugin

import (
"log/slog"
"os"
)

const (
EnvLogLevel = "PLUGIN_SERVER_LOG_LEVEL"
DefaultLogLevel = "info"
DefaultLogLevel = slog.LevelError

EnvListenAddress = "PLUGIN_SERVER_LISTEN_ADDRESS"
DefaultListenAddress = "http://0.0.0.0:8080"
)

func getLogLevel() string {
func GetLogLevel() string {
if logLevel := os.Getenv(EnvLogLevel); logLevel != "" {
return logLevel
}

return DefaultLogLevel
return DefaultLogLevel.String()
}

func getListenAddress() string {
Expand Down
4 changes: 2 additions & 2 deletions plugins/sdk-go/plugin/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ var logger *slog.Logger

func init() {
var logLevel slog.Level
if err := logLevel.UnmarshalText([]byte(getLogLevel())); err != nil {
logLevel = slog.LevelInfo
if err := logLevel.UnmarshalText([]byte(GetLogLevel())); err != nil {
logLevel = DefaultLogLevel
}

logger = slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
Expand Down
1 change: 1 addition & 0 deletions plugins/store/kics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func (s *Scanner) SetStatus(newStatus *types.Status) {
func (s *Scanner) Start(config types.Config) {
go func() {
logger := plugin.GetLogger()
printer.LogLevel(plugin.GetLogLevel(), false)

ctx, cancel := context.WithTimeout(context.Background(), time.Duration(config.TimeoutSeconds)*time.Second)
s.cancel = cancel
Expand Down

0 comments on commit 979ac95

Please sign in to comment.