Sha256: 0f4d4cd360ae0181d952e0813f1e68d82cb717efa9f2169409bbf3893226afbb

Contents?: true

Size: 735 Bytes

Versions: 2

Compression:

Stored size: 735 Bytes

Contents

class GmailCli::Logger

  class << self
    def log(msg)
      $stdout.puts "#{Time.now}| #{msg}"
    end
    def trace(name,value) ; value ; end

    def set_log_mode(verbose)
      if verbose
        class_eval <<-LOGGER_ACTION, __FILE__, __LINE__
          def self.trace(name,value)
            $stderr.puts "\#{Time.now}| \#{name}: \#{value.inspect}"
            value
          end
        LOGGER_ACTION
      else
        class_eval <<-LOGGER_ACTION, __FILE__, __LINE__
          def self.trace(name,value) ; value ; end
        LOGGER_ACTION
      end
    end

  end

end

module GmailCli::LoggerSupport

  def trace(name,value)
    GmailCli::Logger.trace name,value
  end
  def log(msg)
    GmailCli::Logger.log msg
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gmail_cli-0.1.0 lib/gmail_cli/logger.rb
gmail_cli-0.0.1 lib/gmail_cli/logger.rb