Sha256: 03c656e81dcde4ef6975aef262368293841a4cd9495c4ded28a54bfa4a746669

Contents?: true

Size: 994 Bytes

Versions: 6

Compression:

Stored size: 994 Bytes

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

require 'logger'

require_relative 'base_middleware'

module GoodData
  module Bricks
    class LoggerMiddleware < Bricks::Middleware
      def call(params)
        params = params.to_hash
        logger = nil
        if params['GDC_LOGGING_OFF']
          logger = NilLogger.new
        else
          logger = params[:GDC_LOGGER_FILE].nil? ? Logger.new(STDOUT) : Logger.new(params[:GDC_LOGGER_FILE])
          logger.level = params['GDC_LOG_LEVEL'] || 'info'
          logger.info('Pipeline starts')
        end
        params['GDC_LOGGER'] = logger
        GoodData.logging_http_on if params['HTTP_LOGGING'] && params['HTTP_LOGGING'].to_b

        returning(@app.call(params)) do |_result|
          logger.info('Pipeline ending')
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gooddata-1.3.0-java lib/gooddata/bricks/middleware/logger_middleware.rb
gooddata-1.3.0 lib/gooddata/bricks/middleware/logger_middleware.rb
gooddata-1.2.1-java lib/gooddata/bricks/middleware/logger_middleware.rb
gooddata-1.2.1 lib/gooddata/bricks/middleware/logger_middleware.rb
gooddata-1.2.0-java lib/gooddata/bricks/middleware/logger_middleware.rb
gooddata-1.2.0 lib/gooddata/bricks/middleware/logger_middleware.rb