Sha256: 109e6cdfe2e689ce87723f5529eea83f00769d054cf8123a363f75475556db71

Contents?: true

Size: 562 Bytes

Versions: 35

Compression:

Stored size: 562 Bytes

Contents

require "logger"

module Algolia
  class LoggerHelper
    # @param debug_file [nil|String] file used to output the logs
    #
    def self.create(debug_file = nil)
      file = debug_file

      if file.nil? && ENV["ALGOLIA_DEBUG"]
        begin
          file = File.new("debug.log", "a+")
        rescue Errno::EACCES, Errno::ENOENT => e
          puts("Failed to open debug.log: #{e.message}. Falling back to $stderr.")
        end
      end

      instance = ::Logger.new(file || $stderr)
      instance.progname = "algolia"
      instance
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
algolia-3.2.4 lib/algolia/logger_helper.rb
algolia-3.2.3 lib/algolia/logger_helper.rb
algolia-3.2.2 lib/algolia/logger_helper.rb
algolia-3.2.1 lib/algolia/logger_helper.rb
algolia-3.2.0 lib/algolia/logger_helper.rb
algolia-3.1.1 lib/algolia/logger_helper.rb
algolia-3.1.0 lib/algolia/logger_helper.rb
algolia-3.0.2 lib/algolia/logger_helper.rb
algolia-3.0.0 lib/algolia/logger_helper.rb
algolia-3.0.0.beta.16 lib/algolia/logger_helper.rb
algolia-3.0.0.beta.15 lib/algolia/logger_helper.rb
algolia-3.0.0.beta.14 lib/algolia/logger_helper.rb
algolia-3.0.0.beta.13 lib/algolia/logger_helper.rb
algolia-3.0.0.beta.12 lib/algolia/logger_helper.rb
algolia-3.0.0.beta.11 lib/algolia/logger_helper.rb