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 2021/12/15 12:19:50 UTC

[GitHub] [apisix] shuaijinchao commented on a change in pull request #5820: fix(sls-logger): log entry unable get millisecond timestamp

shuaijinchao commented on a change in pull request #5820:
URL: https://github.com/apache/apisix/pull/5820#discussion_r769573844



##########
File path: t/plugin/sls-logger.t
##########
@@ -188,9 +184,38 @@ hello world
             ngx.say(data)
         }
     }
---- request
-GET /t
 --- response_body
 123
---- no_error_log
-[error]
+
+
+
+=== TEST 7: sls log get milliseconds
+--- config
+    location /t {
+        content_by_lua_block {
+            local function get_syslog_timestamp_millisecond(sls_log)
+                local first_idx = string.find(sls_log, " ") + 1
+                local last_idx2 = string.find(sls_log, " ", first_idx)
+                local rfc3339_date = string.sub(sls_log, first_idx, last_idx2)
+                local rfc3339_len = string.len(rfc3339_date)
+                local rfc3339_millisecond = string.sub(rfc3339_date, rfc3339_len - 4, rfc3339_len - 2)
+                return tonumber(rfc3339_millisecond)
+            end
+
+            local rfc5424 = require("apisix.plugins.slslog.rfc5424")
+            local m = 0
+            for _ = 1, 10 do
+                local sls_log = rfc5424.encode("SYSLOG", "INFO", "localhost", "apisix",
+                                              123456, "apisix.apache.org", "apisix.apache.log",
+                                              "apisix.sls.logger", "BD274822-96AA-4DA6-90EC-15940FB24444",
+                                              "hello world")

Review comment:
       updated




-- 
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