gy09535 commented on a change in pull request #2177: URL: https://github.com/apache/apisix/pull/2177#discussion_r518486809
########## File path: apisix/plugins/sls-logger.lua ########## @@ -0,0 +1,213 @@ +-- +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +local core = require("apisix.core") +local log_util = require("apisix.utils.log-util") +local batch_processor = require("apisix.utils.batch-processor") +local plugin_name = "sls-logger" +local ngx = ngx +local rf5424 = require("apisix.plugins.slslog.rfc5424") +local stale_timer_running = false; +local timer_at = ngx.timer.at +local tcp = ngx.socket.tcp +local buffers = {} +local tostring = tostring +local ipairs = ipairs +local schema = { + type = "object", + properties = { + include_req_body = {type = "boolean", default = false}, + name = {type = "string", default = "sls-logger"}, + timeout = {type = "integer", minimum = 1, default= 5000}, + max_retry_count = {type = "integer", minimum = 0, default = 0}, + retry_delay = {type = "integer", minimum = 0, default = 1}, + buffer_duration = {type = "integer", minimum = 1, default = 60}, + inactive_timeout = {type = "integer", minimum = 1, default = 5}, + batch_max_size = {type = "integer", minimum = 1, default = 1000}, + host = {type = "string"}, + port = {type = "integer"}, + project = {type = "string"}, + logstore = {type = "string"}, + access_key_id = {type = "string"}, + access_key_secret = {type ="string"} + }, + required = {"host", "port", "project", "logstore", "access_key_id", "access_key_secret"} +} + +local _M = { + version = 0.1, + priority = 406, + name = plugin_name, + schema = schema, +} + +function _M.check_schema(conf) + return core.schema.check(schema, conf) +end + +local function send_tcp_data(route_conf, log_message) + local err_msg + local res = true + local sock, soc_err = tcp() + local can_close + + if not sock then + err_msg = "failed to init the socket" .. soc_err + core.log.error(err_msg) Review comment: fix ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
