monkeyDluffy6017 commented on code in PR #9712:
URL: https://github.com/apache/apisix/pull/9712#discussion_r1261510288


##########
t/plugin/file-logger2.t:
##########
@@ -274,3 +274,100 @@ passed
     }
 --- response_body
 write file log success
+
+
+
+=== TEST 8: Add new configuration with matches
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                ngx.HTTP_PUT,
+                [[{
+                        "plugins": {
+                            "file-logger": {
+                                "path": "file-with-matches.log",
+                                "matches": [
+                                    [
+                                        [ "arg_name","==","jack" ]
+                                    ]
+                                ],
+                                "log_format": {
+                                    "request": "$request"
+                                }
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1982": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/hello"
+                }]]
+            )
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- response_body
+passed
+
+
+
+=== TEST 9: Request matches
+--- config
+    location /t {
+        content_by_lua_block {
+            local core = require("apisix.core")
+            local t = require("lib.test_admin").test
+            local code = t("/hello?name=jack", ngx.HTTP_GET)
+            local fd, err = io.open("file-with-matches.log", 'r')
+            local msg
+
+            if not fd then
+                core.log.error("failed to open file: file-with-matches.log, 
error info: ", err)
+                return
+            end
+
+            msg = fd:read()

Review Comment:
   ```suggestion
               local fd, err = io.open("file-with-matches.log", 'r')
               if not fd then
                   core.log.error("failed to open file: file-with-matches.log, 
error info: ", err)
                   return
               end            
               local msg = fd:read()
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to