Skip to content
This repository was archived by the owner on Jul 25, 2025. It is now read-only.

Commit da9b591

Browse files
committed
Add fallback Logtail logger configuration in production.rb with error handling for environment variables
1 parent d808950 commit da9b591

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

config/environments/production.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@
7676
# Do not dump schema after migrations.
7777
config.active_record.dump_schema_after_migration = false
7878

79+
# Ensure Logtail is configured in production (fallback if Puma hook doesn't work)
80+
if ENV["LOGTAIL_API_KEY"] && !ENV["LOGTAIL_API_KEY"].empty? && ENV["LOGTAIL_INGESTING_HOST"] && !ENV["LOGTAIL_INGESTING_HOST"].empty?
81+
begin
82+
config.logger = Logtail::Logger.create_default_logger(
83+
ENV["LOGTAIL_API_KEY"],
84+
ingesting_host: ENV["LOGTAIL_INGESTING_HOST"]
85+
)
86+
puts "🌲 Production: Logtail logger configured as fallback"
87+
rescue => e
88+
puts "❌ Production: Failed to configure Logtail fallback: #{e.message}"
89+
end
90+
end
91+
7992
# Enable DNS rebinding protection and other `Host` header attacks.
8093
# config.hosts = [
8194
# "example.com", # Allow requests from example.com

0 commit comments

Comments
 (0)