dabue commented on a change in pull request #2488: URL: https://github.com/apache/apisix/pull/2488#discussion_r513924200
########## File path: apisix/plugins/error-log-logger.lua ########## @@ -0,0 +1,235 @@ +-- +-- 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 plugin_name = "error-log-logger" +local errlog = require "ngx.errlog" +local batch_processor = require("apisix.utils.batch-processor") +local table = core.table +local ngx = ngx +local tcp = ngx.socket.tcp +local select = select +local type = type +local string = string +local tostring = tostring +local buffers +local timer +local schema = { + type = "object", + properties = { + host = {type = "string"}, + port = {type = "integer", minimum = 0}, + tls = {type = "boolean", default = false}, + tls_options = {type = "string"}, + timeout = {type = "integer", minimum = 1, default= 3}, + keepalive = {type = "integer", minimum = 1, default= 30}, + name = {type = "string", default = "tcp logger"}, + level = {type = "string", default = "WARN"}, + batch_max_size = {type = "integer", minimum = 0, default = 1000}, + 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}, + }, + additionalProperties = false, +} + +local log_level = { + STDERR = ngx.STDERR, + EMERG = ngx.EMERG, + ALERT = ngx.ALERT, + CRIT = ngx.CRIT, + ERR = ngx.ERR, + ERROR = ngx.ERR, + WARN = ngx.WARN, + NOTICE = ngx.NOTICE, + INFO = ngx.INFO, + DEBUG = ngx.DEBUG +} + +local config = { + name = plugin_name, + timeout = 3, + keepalive = 30, + level = "WARN", + tls = false, + retry_delay = 1, + batch_max_size = 1000, + max_retry_count = 0, + buffer_duration = 60, + inactive_timeout = 5, +} +local _M = { + version = 0.1, + priority = 1091, + name = plugin_name, + schema = schema, +} + + +function _M.check_schema(conf) + return core.schema.check(schema, conf) +end + + +local function try_attr(t, ...) + local count = select('#', ...) + for i = 1, count do + local attr = select(i, ...) + t = t[attr] + if type(t) ~= "table" then + return false + end + end + + return true +end + +local function load_attr() + local local_conf = core.config.local_conf() + if try_attr(local_conf, "plugin_attr", plugin_name) then + local attr = local_conf.plugin_attr[plugin_name] + config.host = attr.host Review comment: has updated it ---------------------------------------------------------------- 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]
