You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/05/07 04:24:37 UTC

[GitHub] [apisix] tzssangglass commented on a diff in pull request #6960: feat(xRPC): support log filter

tzssangglass commented on code in PR #6960:
URL: https://github.com/apache/apisix/pull/6960#discussion_r867301191


##########
apisix/schema_def.lua:
##########
@@ -807,6 +807,26 @@ local xrpc_protocol_schema = {
             description = "protocol-specific configuration",
             type = "object",
         },
+        logger = {

Review Comment:
   update



##########
apisix/stream/xrpc/runner.lua:
##########
@@ -70,10 +74,54 @@ local function put_req_ctx(session, ctx)
 end
 
 
+local function log_filter(session, ctx)
+    local logger = session._route.protocol.logger
+    if not logger or not logger.filter or #logger.filter == 0 then
+        return false
+    end
+
+    local expr, err = expr.new(logger.filter)
+    if err then
+        core.log.error("failed to validate the 'filter' expression: ", err)
+        return false
+    end
+    return expr:eval(ctx)
+end
+
+
+local function run_log_plugin(session, ctx)
+    local logger = session._route.protocol.logger
+
+    local pkg_name = "apisix.stream.plugins." .. logger.name
+    local ok, plugin = pcall(require, pkg_name)
+
+    core.ctx.set_vars_meta(ctx)
+    ctx.conf_id = tostring(logger.conf)
+    ctx.conf_type = "xrpc-logger"
+
+    if not ok then

Review Comment:
   update



-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org