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

Logs keys order is non deterministic #266

Open
oshirohugo opened this issue Jul 31, 2023 · 0 comments
Open

Logs keys order is non deterministic #266

oshirohugo opened this issue Jul 31, 2023 · 0 comments

Comments

@oshirohugo
Copy link

oshirohugo commented Jul 31, 2023

When using a hclog logger with json format in the plugin side and using json as format, the logs that will be output by the host will show the json keys in a non deterministic order.
For example, changing the Greet method from the basic example to:

func (g *GreeterHello) Greet() string {
	g.logger.Debug("message from GreeterHello.Greet")
	for i := 0; i < 50; i++ {
		g.logger.Debug("##msg from plugin##", "param1", 1, "param2", 2)
	}
	return "Hello!"
}

and running ./basic will show lines like:

2023-07-31T11:53:11.727+0200 [DEBUG] plugin.greeter: ##msg from plugin##: param1=1 param2=2 timestamp=2023-07-31T11:53:11.727+0200
2023-07-31T11:53:11.727+0200 [DEBUG] plugin.greeter: ##msg from plugin##: param2=2 param1=1 timestamp=2023-07-31T11:53:11.727+0200
2023-07-31T11:53:11.727+0200 [DEBUG] plugin.greeter: ##msg from plugin##: param1=1 param2=2 timestamp=2023-07-31T11:53:11.727+0200
2023-07-31T11:53:11.727+0200 [DEBUG] plugin.greeter: ##msg from plugin##: param2=2 param1=1 timestamp=2023-07-31T11:53:11.727+0200

where the order of the log keys is not preserved

@oshirohugo oshirohugo changed the title Logs parameters order is non deterministic Logs keys order is non deterministic Jul 31, 2023
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