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

bug: Logging using pkg/log does not work #149

Open
Blinkuu opened this issue Nov 13, 2023 · 0 comments
Open

bug: Logging using pkg/log does not work #149

Blinkuu opened this issue Nov 13, 2023 · 0 comments

Comments

@Blinkuu
Copy link

Blinkuu commented Nov 13, 2023

Issue description

I followed the blog post describing how to implement an external plugin using Go SDK. I've successfully managed to connect APISIX with my plugin process. On top of that, I can see logs being printed to stdout:

2023-11-13T15:37:38.412Z        INFO    plugin/plugin.go:73     register plugin fault-injection
2023-11-13T15:37:38.412Z        INFO    plugin/plugin.go:73     register plugin limit-req
2023-11-13T15:37:38.412Z        INFO    plugin/plugin.go:73     register plugin response-rewrite
2023-11-13T15:37:38.412Z        INFO    plugin/plugin.go:73     register plugin say
2023-11-13T15:37:38.412Z        WARN    server/server.go:192    conf cache ttl is 1h12m0s
2023-11-13T15:37:38.412Z        WARN    server/server.go:200    listening to /tmp/runner.sock
2023-11-13T15:37:52.667Z        INFO    server/server.go:115    Client connected (unix)
2023-11-13T15:37:52.667Z        INFO    server/server.go:115    Client connected (unix)
2023-11-13T15:37:52.667Z        INFO    server/server.go:131    receive rpc type: 1 data length: 136
2023-11-13T15:37:52.667Z        INFO    plugin/conf.go:98       prepare conf for plugin say
2023-11-13T15:37:52.668Z        INFO    server/server.go:131    receive rpc type: 2 data length: 652
2023-11-13T15:37:52.668Z        INFO    plugin/plugin.go:120    run plugin say
2023-11-13T15:37:53.290Z        INFO    server/server.go:115    Client connected (unix)
2023-11-13T15:37:53.290Z        INFO    server/server.go:115    Client connected (unix)
2023-11-13T15:37:53.290Z        INFO    server/server.go:131    receive rpc type: 2 data length: 652
2023-11-13T15:37:53.291Z        INFO    plugin/plugin.go:120    run plugin say

I tried adding my own logs by importing the github.com/apache/apisix-go-plugin-runner/pkg/log package and using it inside my RequestFilter(...) implementation:

func (p *Say) RequestFilter(conf interface{}, w http.ResponseWriter, r pkgHTTP.Request) {
	log.Infof("Hello from Go plugin!") // This doesn't get printed to `stdout`, no matter the level.

	body := conf.(SayConf).Body
	if len(body) == 0 {
		return
	}
}

However, I actually don't see any logs I created being printed.

Environment

  • APISIX Go Plugin Runner's version: v0.5.0
  • APISIX version: 3.6.0
  • Go version: 1.21.3
  • OS (cmd: uname -a): Docker container based on golang:1.21-bullseye image

Minimal test code / Steps to reproduce the issue

N/A

What's the actual result? (including assertion message & call stack if applicable)

I see both INFO and WARN logs from places like server/server.go and plugin/plugin.go.

What's the expected result?

I expect to see my own logs.

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