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

Apply zerolog to some parts of mcis dynamic provision #1479

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

seokho-son
Copy link
Member

Found

Trying to apply it to some parts of mcis dynamic provision.

@seokho-son
Copy link
Member Author

PTAL: @yunkon-kim :)

Copy link
Member

@yunkon-kim yunkon-kim left a comment

Choose a reason for hiding this comment

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

@seokho-son LGTM!

I'd like to share two useful usages.

@seokho-son
Copy link
Member Author

@yunkon-kim
So..

err := fmt.Errorf("Failed to get the vNet " + vmReq.VNetId + " from " + vmReq.ConnectionName)
log.Error().Err(err).Msg("Failed to get the vNet")

--> log.Error().Err(err).Msg("") is a better usage?

@yunkon-kim
Copy link
Member

yunkon-kim commented Apr 1, 2024

@seokho-son It depends on errors. The current code looks fine to me.

Here's an example code and result:

err := fmt.Errorf("error message from err objects")
	log.Error().Err(err).Msg("my error message")

Console
image

Log file

{"level":"error","error":"error message from err objects","time":"2024-04-01T17:15:54+09:00","caller":"/home/ubuntu/dev/cloud-barista/cb-tumblebug/src/api/rest/server/server.go:88","message":"my error message"}

As you can see the example,

  • .Err(err) makes error field for logging (see Advanced Fields), and
  • .Msg() is a general message field for all log levels.

@seokho-son
Copy link
Member Author

@yunkon-kim Thanks! then, let's keep the current. Please approve (merge) if it is ok. :)

@yunkon-kim yunkon-kim merged commit bd6603e into cloud-barista:main Apr 1, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants