Class: Backend::Logger — Documentation by YARD 0.9.12

# Class: Backend::Logger

Inherits:
  Object
  - Object
  - Backend::Logger
  show all

Defined in:
  logger.rb

## Overview

Class that implements a logger to write output in the backend logs

## Class Method Summary collapse

- .info(method, host, port, path, response, start_time) ⇒ Object
- .reset_runtime ⇒ Object
- .runtime ⇒ Object

## Class Method Details

### .info(method, host, port, path, response, start_time) ⇒ `Object`

    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    # File 'logger.rb', line 15

    def self.info(method, host, port, path, response, start_time)
      time_delta = Time.now - start_time
      now = Time.now.strftime '%Y%m%dT%H%M%S'
      @backend_logger.info "#{now} #{method} #{host}:#{port}#{path} #{response.code} #{time_delta}"
      @backend_time += time_delta
      Rails.logger.debug "request took #{time_delta} #{@backend_time}"

      return unless CONFIG['extended_backend_log']

      data = response.body
      if data.nil?
        @backend_logger.info '(no data)'
      elsif data.class == 'String' && data[0, 1] == '<'
        @backend_logger.info data
      else
        @backend_logger.info "(non-XML data) #{data.class}"
      end
    end

### .reset_runtime ⇒ `Object`

    7
    8
    9
    # File 'logger.rb', line 7

    def self.reset_runtime
      @backend_time = 0
    end

### .runtime ⇒ `Object`

    11
    12
    13
    # File 'logger.rb', line 11

    def self.runtime
      @backend_time
    end