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.11.0 lib/algolia/logger_helper.rb
algolia-3.10.2 lib/algolia/logger_helper.rb
algolia-3.10.1 lib/algolia/logger_helper.rb
algolia-3.8.2 lib/algolia/logger_helper.rb
algolia-3.8.1 lib/algolia/logger_helper.rb
algolia-3.8.0 lib/algolia/logger_helper.rb
algolia-3.7.1 lib/algolia/logger_helper.rb
algolia-3.7.0 lib/algolia/logger_helper.rb
algolia-3.6.0 lib/algolia/logger_helper.rb
algolia-3.5.4 lib/algolia/logger_helper.rb
algolia-3.5.3 lib/algolia/logger_helper.rb
algolia-3.5.2 lib/algolia/logger_helper.rb
algolia-3.5.1 lib/algolia/logger_helper.rb
algolia-3.5.0 lib/algolia/logger_helper.rb
algolia-3.4.0 lib/algolia/logger_helper.rb
algolia-3.3.4 lib/algolia/logger_helper.rb
algolia-3.3.3 lib/algolia/logger_helper.rb
algolia-3.3.2 lib/algolia/logger_helper.rb
algolia-3.3.1 lib/algolia/logger_helper.rb
algolia-3.3.0 lib/algolia/logger_helper.rb