From dc9647b40529e64fa71f75cbdb350d2c36fd2867 Mon Sep 17 00:00:00 2001 From: Devin Christensen Date: Wed, 27 Aug 2014 14:09:16 -0600 Subject: [PATCH 1/2] Never close $stdout --- lib/protobuf/logging.rb | 10 +--------- spec/spec_helper.rb | 2 -- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/protobuf/logging.rb b/lib/protobuf/logging.rb index 47f5b8f3..5ee649b9 100644 --- a/lib/protobuf/logging.rb +++ b/lib/protobuf/logging.rb @@ -6,18 +6,10 @@ def self.initialize_logger(log_target=$stdout, log_level=::Logger::INFO) old_logger = defined?(@logger) ? @logger : nil @logger = Logger.new(log_target) @logger.level = log_level - old_logger.close if old_logger and close_old_logger? + old_logger.close if old_logger and log_target != $stdout @logger end - def self.close_old_logger=(boolean) - @close_old_logger = !!boolean - end - - def self.close_old_logger? - defined?(@close_old_logger) ? @close_old_logger : true - end - def self.logger defined?(@logger) ? @logger : initialize_logger end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 414f80d5..fa22f2ce 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -23,8 +23,6 @@ ::Protobuf::Logging.initialize_logger('/dev/null') end -::Protobuf::Logging.close_old_logger = false - # Get rid of the deprecation env var if present (messes with specs). ENV.delete("PB_IGNORE_DEPRECATIONS") From a8e071c80621fd9ab463b6672b9e46e8acc036cd Mon Sep 17 00:00:00 2001 From: Devin Christensen Date: Wed, 27 Aug 2014 14:22:54 -0600 Subject: [PATCH 2/2] Never close old logger There's not a great way to handle automatically closing old file descriptors, so I'm just going to leave it out for now. --- lib/protobuf/logging.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/protobuf/logging.rb b/lib/protobuf/logging.rb index 5ee649b9..78a5aea6 100644 --- a/lib/protobuf/logging.rb +++ b/lib/protobuf/logging.rb @@ -3,10 +3,8 @@ module Logging def self.initialize_logger(log_target=$stdout, log_level=::Logger::INFO) @counter ||= 0 @counter = @counter + 1 - old_logger = defined?(@logger) ? @logger : nil @logger = Logger.new(log_target) @logger.level = log_level - old_logger.close if old_logger and log_target != $stdout @logger end