lib/logtail-rails/logger.rb in logtail-rails-0.1.7 vs lib/logtail-rails/logger.rb in logtail-rails-0.1.8
- old
+ new
@@ -13,8 +13,26 @@
if defined?(::ActiveSupport::LoggerSilence)
include ::ActiveSupport::LoggerSilence
elsif defined?(::LoggerSilence)
include ::LoggerSilence
end
+
+ def self.create_logger(*io_devices_and_loggers)
+ logger = Logtail::Logger.new(*io_devices_and_loggers)
+
+ tagged_logging_supported = Rails::VERSION::MAJOR >= 7 || Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR >= 1
+ logger = ::ActiveSupport::TaggedLogging.new(logger) if tagged_logging_supported
+
+ logger
+ end
+
+ def self.create_default_logger(source_token)
+ if ENV['LOGTAIL_SKIP_LOGS'].blank? && !Rails.env.test?
+ io_device = Logtail::LogDevices::HTTP.new(source_token)
+ else
+ io_device = STDOUT
+ end
+
+ self.create_logger(io_device)
+ end
end
end
-