Skip to content

Commit

Permalink
Merge branch 'master' into AST-67161-Add-Score-System
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonardoLordelloFontes authored Nov 26, 2024
2 parents f4814ed + f5a5cb4 commit 3f05b72
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cmd/exit_handler.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"github.com/rs/zerolog/log"
"os"
)

Expand All @@ -27,6 +28,7 @@ func isNeedReturnErrorCodeFor(kind ignoreOnExit) bool {

func exitCodeIfError(err error) int {
if err != nil && isNeedReturnErrorCodeFor("errors") {
log.Error().Err(err).Msg("Failed to run 2ms")
return errorCode
}

Expand Down
5 changes: 2 additions & 3 deletions lib/utils/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ func (w SpecificLevelWriter) WriteLevel(level zerolog.Level, p []byte) (int, err
func CreateLogger(minimumLevel zerolog.Level) zerolog.Logger {
writer := zerolog.MultiLevelWriter(
SpecificLevelWriter{
Writer: zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: "15:04:05"},
Writer: zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: "15:04:05", NoColor: true},
Levels: []zerolog.Level{
zerolog.DebugLevel, zerolog.InfoLevel, zerolog.WarnLevel,
},
},
SpecificLevelWriter{
Writer: zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: "15:04:05"},
Writer: zerolog.ConsoleWriter{Out: os.Stderr, TimeFormat: "15:04:05", NoColor: true},
Levels: []zerolog.Level{
zerolog.ErrorLevel, zerolog.FatalLevel, zerolog.PanicLevel,
},
},
)

return zerolog.New(writer).Level(minimumLevel).With().Timestamp().Logger()
}
3 changes: 3 additions & 0 deletions plugins/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"os"
"path/filepath"
"sync"
"time"

"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -93,6 +94,7 @@ func (p *FileSystemPlugin) getFiles(items chan ISourceItem, errs chan error, wg

if err != nil {
errs <- fmt.Errorf("error while walking through the directory: %w", err)
time.Sleep(time.Second) // Temporary fix for incorrect non-error exits; needs a better solution.
return
}

Expand All @@ -107,6 +109,7 @@ func (p *FileSystemPlugin) getItems(items chan ISourceItem, errs chan error, wg
actualFile, err := p.getItem(filePath)
if err != nil {
errs <- err
time.Sleep(time.Second) // Temporary fix for incorrect non-error exits; needs a better solution.
return
}
items <- *actualFile
Expand Down

0 comments on commit 3f05b72

Please sign in to comment.