-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5390 from snyk/chore/CLI-409_improve_logging
chore(logging): Improve and fix issues in trace level logging
- Loading branch information
Showing
7 changed files
with
84 additions
and
60 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
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,24 @@ | ||
package debug | ||
|
||
import ( | ||
"github.com/rs/zerolog" | ||
"github.com/snyk/go-application-framework/pkg/configuration" | ||
) | ||
|
||
func GetDebugLevel(config configuration.Configuration) zerolog.Level { | ||
loglevel := zerolog.Disabled | ||
|
||
if config.GetBool(configuration.DEBUG) { | ||
loglevel = zerolog.DebugLevel | ||
|
||
if loglevelString := config.GetString(configuration.LOG_LEVEL); loglevelString != "" { | ||
var err error | ||
loglevel, err = zerolog.ParseLevel(loglevelString) | ||
if err != nil { | ||
loglevel = zerolog.DebugLevel | ||
} | ||
} | ||
} | ||
|
||
return loglevel | ||
} |
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