Skip to content

Commit

Permalink
Update logger configuration to use logrus and viper
Browse files Browse the repository at this point in the history
Signed-off-by: Aviral0702 <aviral.asthana0704@gmail.com>
  • Loading branch information
Aviral0702 committed Jun 21, 2024
1 parent 6ebe5b3 commit 8157ff7
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions docs/pages/project/contributing/contributing-error.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ import (

meshkitErrors "github.com/layer5io/meshkit/errors"
"github.com/layer5io/meshkit/logger"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)

var (
Expand All @@ -140,9 +142,13 @@ var (
)

func main() {
logLevel := viper.GetInt("LOG_LEVEL")
if viper.GetBool("DEBUG") {
logLevel = int(logrus.DebugLevel)
}
log, err := logger.New("test", logger.Options{
Format: logger.SyslogLogFormat,
LogLevel: logLevel,
Format: logger.SyslogLogFormat,
LogLevel: logLevel,
})
if err != nil {
fmt.Println(err)
Expand Down Expand Up @@ -189,9 +195,9 @@ func openFileWithMeshkitError(name string) error {

func ErrOpeningFile(err error) error {
return meshkitErrors.New(ErrOpeningFileCode, meshkitErrors.Alert, []string{"unable to open file"},
[]string{err.Error()},
[]string{"empty string passed as argument ", "file with this name doesn't exist"},
[]string{"pass a non-empty string as filename ", "create file before opening it"})
[]string{err.Error()},
[]string{"empty string passed as argument ", "file with this name doesn't exist"},
[]string{"pass a non-empty string as filename ", "create file before opening it"})
}{% endcapture %}
{% include code.html code=code_content %}

0 comments on commit 8157ff7

Please sign in to comment.