-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Updated Meshkit logger docs #11202
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8f4146c
Updated error handling in contributing-error.md file
Aviral0702 fe98fb3
updated the Meshkit error docs
Aviral0702 c01f68b
Fix indentation issue in logger initialization code
Aviral0702 b352a6c
Updated indentations
Aviral0702 6ebe5b3
Merge branch 'meshery:master' into master
Aviral0702 8157ff7
Update logger configuration to use logrus and viper
Aviral0702 c827505
Merge branch 'meshery:master' into master
Aviral0702 b2fabaf
Merge branch 'meshery:master' into master
Aviral0702 690d487
Merge branch 'meshery:master' into master
Aviral0702 46b06a5
Update error handling in main function
Aviral0702 78fd894
Update error handling in main function
Aviral0702 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ( | ||
|
@@ -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{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Aviral0702 You can take a look to this example set the |
||
Format: logger.SyslogLogFormat, | ||
DebugLevel: true, | ||
Format: logger.SyslogLogFormat, | ||
LogLevel: logLevel, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maintain the indentation |
||
}) | ||
if err != nil { | ||
fmt.Println(err) | ||
|
@@ -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 %} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
Try to run this code provided and see what does it show and please replace it if you would.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok Sir