From bec9f5eb2e46fc154ed33f2402321efbe242dea5 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 8 Jan 2019 14:27:25 +1100 Subject: [PATCH] Move sample data logger to own module --- lib/tasks/sample_data.rake | 10 ++-------- lib/tasks/sample_data/logging.rb | 8 ++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 lib/tasks/sample_data/logging.rb diff --git a/lib/tasks/sample_data.rake b/lib/tasks/sample_data.rake index d93300e51f..a78ff15ae7 100644 --- a/lib/tasks/sample_data.rake +++ b/lib/tasks/sample_data.rake @@ -1,3 +1,5 @@ +require "tasks/sample_data/logging" + # The sample data generated by this task is supposed to save some time during # manual testing. It is not meant to be complete, but we try to improve it # over time. How much is hardcoded here is a trade off between developer time @@ -44,14 +46,6 @@ namespace :openfoodnetwork do Spree::State.count > 0 end - module Logging - private - - def log(message) - puts "[openfoodnetwork:sample_data:load] #{message}" - end - end - module Addressing private diff --git a/lib/tasks/sample_data/logging.rb b/lib/tasks/sample_data/logging.rb new file mode 100644 index 0000000000..ed68d7e52e --- /dev/null +++ b/lib/tasks/sample_data/logging.rb @@ -0,0 +1,8 @@ +module Logging + private + + def log(message) + @logger ||= ActiveSupport::TaggedLogging.new(Logger.new(STDOUT)) + @logger.tagged("openfoodnetwork:sample_data:load") { @logger.info(message) } + end +end