Sha256: 6cb545e53cd546270ee290838c28794aa1bcbe5ac273444d0676eeda1ea9751f

Contents?: true

Size: 889 Bytes

Versions: 5

Compression:

Stored size: 889 Bytes

Contents

module Napa
  class Logger
    class << self
      def name
        [Napa::Identity.name, Napa::LogTransaction.id].join('-')
      end

      def logger=(logger)
        @logger = logger
      end

      def logger
        unless @logger
          Logging.appenders.stdout(
            'stdout',
            layout: Logging.layouts.json
          )
          Logging.appenders.file(
            "log/#{Napa.env}.log",
            layout: Logging.layouts.json
          )

          @logger = Logging.logger["[#{name}]"]
          @logger.add_appenders 'stdout' unless Napa.env.test?
          @logger.add_appenders "log/#{Napa.env}.log"
        end

        @logger
      end

      def response(status, headers, body)
        { response:
          {
            status:   status,
            headers:  headers,
            response: body
          }
        }
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
napa-0.5.0 lib/napa/logger/logger.rb
napa-0.4.3 lib/napa/logger/logger.rb
napa-0.4.1 lib/napa/logger/logger.rb
napa-0.4.0 lib/napa/logger/logger.rb
napa-0.3.0 lib/napa/logger/logger.rb