class QB::Ansible::QB::Ansible::QB::Ansible::Module::Formatters::JSON

Public Class Methods

new(time_format: :iso_8601, log_host: true, log_application: true, time_key: :timestamp) click to toggle source

Default JSON time format is ISO8601

Calls superclass method
# File lib/qb/ansible/module.rb, line 87
def initialize  time_format: :iso_8601,
                log_host: true,
                log_application: true,
                time_key: :timestamp
  super(
    time_format: time_format,
    log_host: log_host,
    log_application: log_application,
    time_key: time_key,
  )
end

Public Instance Methods

call(log, logger) click to toggle source
Calls superclass method
# File lib/qb/ansible/module.rb, line 99
def call log, logger
  raw = super( log, logger )
  
  begin
    raw.to_json
  rescue Exception => error
    # SemanticLogger::Processor.instance.appender.logger.warn \
    #   "Unable to JSON encode for logging", raw: raw
    
    $stderr.puts "Unable to JSON encode log"
    $stderr.puts raw.pretty_inspect
    
    raise
  end
end