Class: FHTTPClient::Log

Inherits:
Service
  • Object
show all
Defined in:
lib/f_http_client/log.rb

Overview

Allow to log a message to system log

Attributes:

  • message: object containint the message to be logged;

  • level (optional): level symbol to log the message (debug, info, warn error, fatal or unknown);

  • tags (optional): list of tags to be added to log line.

Example:

FHTTPClient::Log.(message: { name: 'Bruno' }.to_json)
FHTTPClient::Log.(message: { name: 'Bruno' }.to_json, stragegy: :rails)
FHTTPClient::Log.(message: { name: 'Bruno' }.to_json, tags: ['Response'])
FHTTPClient::Log.(message: { response: { name: 'Bruno' } }.to_json, level: :warn)

Instance Method Summary collapse

Instance Method Details

#loggerObject



34
35
36
# File 'lib/f_http_client/log.rb', line 34

def logger
  @logger ||= LOGGERS.fetch(strategy, FHTTPClient::Logger::Null).new
end

#runObject



28
29
30
31
32
# File 'lib/f_http_client/log.rb', line 28

def run
  logger.tagged(*Array(tags)).public_send(level, message)

  Success(:logged)
end