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

Fields with map[string]string #648

Open
luisdavim opened this issue Feb 8, 2024 · 0 comments
Open

Fields with map[string]string #648

luisdavim opened this issue Feb 8, 2024 · 0 comments

Comments

@luisdavim
Copy link

Currently fields doesn't support map[string]string.

Example:

package main

import (
	"os"

	"github.com/rs/zerolog"
)

func main() {
	fields := map[string]string{
		"bar": "baz",
		"n":   "1",
	}

	log := zerolog.New(os.Stdout)

	log.Log().
		Str("foo", "bar").
		Fields(fields).
		Msg("hello world")

}

results in:

{"foo":"bar","message":"hello world"}

whilst:

package main

import (
	"os"

	"github.com/rs/zerolog"
)

func main() {
	fields := map[string]interface{}{
		"bar": "baz",
		"n":   "1",
	}

	log := zerolog.New(os.Stdout)

	log.Log().
		Str("foo", "bar").
		Fields(fields).
		Msg("hello world")

}

outputs:

{"foo":"bar","bar":"baz","n":"1","message":"hello world"}
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

No branches or pull requests

1 participant