40. Rails からの利用
class CookpadLogger
class RailsLogger < ::Fluent::Logger::TextLogger
def initialize(rails_logger)
super()
@rails_logger = rails_logger
end
def post_text(text)
@rails_logger.
debug("[CookpadLogger]t" + text)
end
end
41. Rails からの利用
class CookpadLogger
def self.create_logger(tag = 'cookpad')
case Rails.env
when 'production'
Fluent::Logger::FluentLogger.new(tag)
when 'test'
Fluent::Logger::TestLogger.new
else
RailsLogger.new(Rails.logger)
end
end