We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e84f5e5 commit d91ecc8Copy full SHA for d91ecc8
clients/algoliasearch-client-ruby/lib/algolia/logger_helper.rb
@@ -5,8 +5,17 @@ class LoggerHelper
5
# @param debug_file [nil|String] file used to output the logs
6
#
7
def self.create(debug_file = nil)
8
- file = debug_file || (ENV["ALGOLIA_DEBUG"] ? File.new("debug.log", "a+") : $stderr)
9
- instance = ::Logger.new(file)
+ file = debug_file
+
10
+ if file.nil? && ENV["ALGOLIA_DEBUG"]
11
+ begin
12
+ file = File.new("debug.log", "a+")
13
+ rescue Errno::EACCES, Errno::ENOENT => e
14
+ puts "Failed to open debug.log: #{e.message}. Falling back to $stderr."
15
+ end
16
17
18
+ instance = ::Logger.new(file || $stderr)
19
instance.progname = "algolia"
20
instance
21
end
0 commit comments