Skip to content

Logs keys order is non deterministic  #266

@oshirohugo

Description

@oshirohugo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions