Class: Rack::Access::Capture::Collector::FluentdAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- Rack::Access::Capture::Collector::FluentdAdapter
- Defined in:
- lib/rack/access/capture/collector/fluentd_adapter.rb
Instance Attribute Summary collapse
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #collect(log) ⇒ Object
- #collect?(env) ⇒ Boolean
-
#initialize(options = {}) ⇒ FluentdAdapter
constructor
A new instance of FluentdAdapter.
Constructor Details
#initialize(options = {}) ⇒ FluentdAdapter
Returns a new instance of FluentdAdapter.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rack/access/capture/collector/fluentd_adapter.rb', line 13 def initialize( = {}) config = || {} @tag = config["tag"] || 'development' tag_prefix = config["tag_prefix"] host = config["host"] || 'localhost' port = config["port"] || 24224 handler = proc { || BufferOverflowHandler.new(config["log_file_path"]).flush() } buffer_limit = config["buffer_limit"] || 131072 # Buffer limit of the standard is 128.kilobyte log_reconnect_error_threshold = config["log_reconnect_error_threshold"] || Fluent::Logger::FluentLogger::RECONNECT_WAIT_MAX_COUNT = { host: host, port: port, buffer_limit: buffer_limit, buffer_overflow_handler: handler, log_reconnect_error_threshold: log_reconnect_error_threshold } @logger = config["logger"] || Fluent::Logger::FluentLogger.new(tag_prefix, ) exclude_request = config["exclude_request"] || [] @collect = [GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, LINK, UNLINK, TRACE] - exclude_request end |
Instance Attribute Details
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
11 12 13 |
# File 'lib/rack/access/capture/collector/fluentd_adapter.rb', line 11 def tag @tag end |
Instance Method Details
#collect(log) ⇒ Object
36 37 38 |
# File 'lib/rack/access/capture/collector/fluentd_adapter.rb', line 36 def collect(log) @logger.post(@tag, log) end |
#collect?(env) ⇒ Boolean
32 33 34 |
# File 'lib/rack/access/capture/collector/fluentd_adapter.rb', line 32 def collect?(env) @collect.include?(env["REQUEST_METHOD"]) end |