Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Meshkit logger docs #11202

Merged
merged 11 commits into from
Jul 1, 2024
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 (
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After the recent meshkit release we don't show panic error anymore so if you replace that part too it would be great.
Else current update LGTM.
Screenshot from 2024-06-21 20-45-12

Try to run this code provided and see what does it show and please replace it if you would.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review. I am trying to implement the changes as you said.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have run this code but there was no output when the logLevel was the value of LOG_LEVEL but when I set the logLevel = logrus.InfoLevel then error occurred for the missing some.txt file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, right on the head that is the error that is displayed now so you can replace the panic error with the error you see and then we can be GTG with the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok Sir


func main() {
logLevel := viper.GetInt("LOG_LEVEL")
if viper.GetBool("DEBUG") {
logLevel = int(logrus.DebugLevel)
}
log, err := logger.New("test", logger.Options{
Copy link
Contributor

@singh1203 singh1203 Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Aviral0702 You can take a look to this example set the logLevel from here

Format: logger.SyslogLogFormat,
DebugLevel: true,
Format: logger.SyslogLogFormat,
LogLevel: logLevel,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maintain the indentation

})
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 %}

Loading