apache / apache/apisix-go-plugin-runner

bug: Logging using `pkg/log` does not work

Open
#149 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
198
Forks
68
PR merge metrics
No merged PRs in 30d

Description

### Issue description
I followed the [blog post](https://apisix.apache.org/blog/2021/08/19/go-makes-apache-apisix-better/) 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:

```go
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.