From e50da2e4e763ad00acbdf5b18bef68570678e8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 11 Jul 2013 16:24:10 +0200 Subject: [PATCH] Feature #2027: Create oneflow log dir if it does not exist --- src/flow/lib/log.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/flow/lib/log.rb b/src/flow/lib/log.rb index 3f6aaef4b5..f316c63726 100644 --- a/src/flow/lib/log.rb +++ b/src/flow/lib/log.rb @@ -132,12 +132,20 @@ class Log end begin - open("#{LOG_LOCATION}/oneflow/#{service_id}.log", 'a') do |f| - f << MSG_FORMAT % [ + msg = MSG_FORMAT % [ Time.now.strftime(DATE_FORMAT), Logger::SEV_LABEL[severity][0..0], component, message ] + + open("#{LOG_LOCATION}/oneflow/#{service_id}.log", 'a') do |f| + f << msg + end + rescue Errno::ENOENT => e + FileUtils.mkdir("#{LOG_LOCATION}/oneflow/") + + open("#{LOG_LOCATION}/oneflow/#{service_id}.log", 'a') do |f| + f << msg end rescue => e message = "Could not log into #{LOG_LOCATION}/oneflow/#{service_id}.log: #{e.message}"