Sha256: 1ce8ce70db0066290065256d3ae369569c94418dc2c80cb77276e400b3013591

Contents?: true

Size: 766 Bytes

Versions: 2

Compression:

Stored size: 766 Bytes

Contents

module Pakyow
  
  # Provides an easy way to log text, warnings, etc.
  class Log
    
    # Adds text to the log. 
    def self.puts(text = "")
      return if !Configuration::Base.app.log
      
      @@console ||= Logger.new($stdout)
      @@console << "#{text}\r\n"
      
      dir = "#{Configuration::Base.app.log_dir}"
      
      if File.exists?(dir)
        @@file ||= Logger.new("#{dir}/#{Configuration::Base.app.log_name}")
        @@file    << "#{text}\r\n"
      end    
    end

    class << self
      alias :enter :puts
    end
    
    # Adds warning text to the log.
    def self.warn(text)
      Log.enter("WARNING: #{text}")
    end

    # Adds error text to the log.
    def self.error(text)
      Log.enter("ERROR: #{text}")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pakyow-core-0.6.3.1 pakyow-core/lib/core/log.rb
pakyow-core-0.6.1 pakyow-core/lib/core/log.rb