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

Adding Event.Type(...) method to log the type of an object #437

Merged
merged 4 commits into from
Oct 18, 2022

Conversation

w3aponx
Copy link
Contributor

@w3aponx w3aponx commented Apr 26, 2022

I found myself wanting to log the type of an object and was convinced there would be a method to do that already, but I didn't find one. Here's a case where one might want such a method:

	var value interface{}
	var result string
	switch v := value.(type) {
	case int:
		result = strconv.Itoa(v)
	case string:
		result = v
	default:
		log.Panic().Type("type", v).Msg("Unexpected value type")
	}
	log.Info().Msg(result)

Let me know if there's anything else that needs to change for this to get accepted.

internal/json/types.go Outdated Show resolved Hide resolved
Better test labeling.
@w3aponx w3aponx requested a review from rs August 16, 2022 16:12
@w3aponx
Copy link
Contributor Author

w3aponx commented Oct 18, 2022

@rs are you waiting for any more changes here? Just wanted to make sure because AFAIK the requested changes were implemented a while back and I'm not sure how I can convey that any better than by requesting another review. If it's just that you've been busy with other stuff, no worries -- just wanted to ensure you weren't waiting for something on my part.

@rs rs merged commit 89617ff into rs:master Oct 18, 2022
pablitoc pushed a commit to nxcr-org/zerolog that referenced this pull request Apr 7, 2023
Co-authored-by: Mario Cormier <mcormier@rossvideo.com>
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.

None yet

2 participants