class SemanticLogger::Appender::ElasticsearchHttp
def delete_all(date = Date.today)
def delete_all(date = Date.today) delete(date.strftime(@request_path)) end
def initialize(index: "semantic_logger",
Name of this application to appear in log messages.
application: [String]
Default: SemanticLogger.host
Name of this host to appear in log messages.
host: [String]
The Proc must return true or false.
Proc: Only include log messages where the supplied Proc returns true
regular expression. All other messages will be ignored.
RegExp: Only include log messages where the class name matches the supplied.
filter: [Regexp|Proc]
Default: Use the built-in formatter (See: #call)
the output from this appender
An instance of a class that implements #call, or a Proc to be used to format
formatter: [Object|Proc|Symbol|Hash]
Default: SemanticLogger.default_level
Override the log level for this appender.
level: [:trace | :debug | :info | :warn | :error | :fatal]
Default: 'log'
Deprecated in Elasticsearch 7.0.0
Document type to associate with logs when they are written.
type: [String]
Default: 'semantic_logger'
I.e. The final index will look like 'semantic_logger-YYYY.MM.DD'
The final index appends the date so that indexes are used per day.
Prefix of the index to store the logs in Elasticsearch.
index: [String]
Parameters:
Create Elasticsearch appender over persistent HTTP(S)
def initialize(index: "semantic_logger", type: "log", url: "http://localhost:9200", **http_args, &block) @index = index @type = type super(url: url, **http_args, &block) @request_path = "#{@path.end_with?('/') ? @path : "#{@path}/"}#{@index}-%Y.%m.%d" @logging_path = "#{@request_path}/#{type}" end
def log(log)
def log(log) post(formatter.call(log, self), log.time.strftime(@logging_path)) end