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

logger: Do not set location offset in go-plugin #190

Merged
merged 1 commit into from
Sep 5, 2022
Merged

Conversation

wata727
Copy link
Member

@wata727 wata727 commented Sep 5, 2022

The log output includes the line number in an assembler, which is clearly wrong.

12:42:42 [WARN]  [email protected]/client.go:355: plugin configured with a nil SecureConfig
12:42:42 [DEBUG] [email protected]/client.go:355: starting plugin: path=/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws args=["/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws"]
12:42:42 [DEBUG] [email protected]/client.go:355: plugin started: path=/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws pid=17795
12:42:42 [DEBUG] [email protected]/client.go:355: waiting for RPC address: path=/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws
12:42:42 [DEBUG] [email protected]/client.go:355: using plugin: version=10
12:42:42 [DEBUG] runtime/asm_amd64.s:1594: tflint-ruleset-aws: 12:42:42 [DEBUG] host2plugin/server.go:38: plugin address: network=unix address=/tmp/plugin935001403
12:42:42 provider.go:64: [INFO] Prepare rules
12:42:42 provider.go:92: [INFO]   5 default rules enabled
12:42:42 [DEBUG] host2plugin/client.go:101: starting host-side gRPC server
12:42:42 [DEBUG] runtime/asm_amd64.s:1594: stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
12:42:42 [INFO]  runtime/asm_amd64.s:1594: plugin process exited: path=/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws pid=17795
12:42:42 [DEBUG] plugin/plugin.go:26: plugin exited

This is because the hclog.Logger passed to the go-plugin has an AdditionalLocationOffset. Do not set an offset here.
By removing the offset from the logger passed to go-plugin, you can output the correct log as follows:

12:38:45 [WARN]  [email protected]/client.go:551: plugin configured with a nil SecureConfig
12:38:45 [DEBUG] [email protected]/client.go:585: starting plugin: path=/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws args=["/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws"]
12:38:45 [DEBUG] [email protected]/client.go:593: plugin started: path=/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws pid=16234
12:38:45 [DEBUG] [email protected]/client.go:688: waiting for RPC address: path=/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws
12:38:45 [DEBUG] [email protected]/client.go:736: using plugin: version=10
12:38:45 [DEBUG] [email protected]/client.go:1030: tflint-ruleset-aws: 12:38:45 [DEBUG] host2plugin/server.go:38: plugin address: network=unix address=/tmp/plugin849619141
12:38:45 provider.go:64: [INFO] Prepare rules
12:38:45 provider.go:92: [INFO]   5 default rules enabled
12:38:45 [DEBUG] host2plugin/client.go:101: starting host-side gRPC server
12:38:45 [DEBUG] [email protected]/grpc_stdio.go:139: stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
12:38:45 [INFO]  [email protected]/client.go:646: plugin process exited: path=/home/codespace/.tflint.d/plugins/github.com/terraform-linters/tflint-ruleset-aws/0.16.1/tflint-ruleset-aws pid=16234
12:38:45 [DEBUG] [email protected]/client.go:461: plugin exited

@wata727 wata727 merged commit b711cbe into master Sep 5, 2022
@wata727 wata727 deleted the tweak_logging branch September 5, 2022 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant