Module: Suture::Wrap::Logger
- Defined in:
- lib/suture/wrap/logger.rb
Defined Under Namespace
Classes: NullIO
Class Method Summary collapse
Class Method Details
.init(options) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/suture/wrap/logger.rb', line 5 def self.init() @logger = if [:log_file] full_path = File.join(Dir.getwd, [:log_file]) FileUtils.mkdir_p(File.dirname(full_path)) ::Logger.new(full_path) else ::Logger.new(NullIO.new) end @logger.level = if [:log_level] ::Logger.const_get([:log_level]) else ::Logger::INFO end @logger.formatter = proc { |_, time , _, msg| formatted_time = time.strftime("%Y-%m-%dT%H:%M:%S.%6N") "[#{formatted_time}] Suture: #{msg}\n".tap { |out| puts out if [:log_stdout] [:log_io].write(out) if [:log_io] } } return @logger end |