Sha256: 213ff78ba07587817f7feb13c41d1b67f82cd5de7d2df757969ae26ca2668de2

Contents?: true

Size: 1.17 KB

Versions: 80

Compression:

Stored size: 1.17 KB

Contents

unless self.respond_to?("log!")
  $logging = true
  $log = File.new("/tmp/runeblog.log","w")

  def outlog(str = "", stderr: false)
    $log.puts str
    STDERR.puts str if stderr
  end

  def log!(str: "", enter: nil, args: [], pwd: false, dir: false, level: 0, stderr: false)
    return unless $logging
    @err_level ||= ENV['RUNEBLOG_ERROR_LEVEL']
    @err_level ||= 0
    return if level < @err_level 

    time = Time.now.strftime("%H:%M:%S")

    meth = ""
    meth = "#{enter}" if enter

    para = "(#{args.inspect[1..-2]})"

    source = caller[0].sub(/.*\//, " in ").sub(/:/, " line ").sub(/:.*/, "")
    source = "in #{source} (probably liveblog.rb)" if source.include? "(eval)"

    str = "  ... #{str}" unless str.empty?
    indent = " "*12

    outlog "#{time} #{meth}#{para}"
    outlog "#{indent} #{str} " unless str.empty?
    outlog "#{indent} #{source}"
    outlog "#{indent} pwd = #{Dir.pwd} " if pwd
    if dir
      files = (Dir.entries('.') - %w[. ..]).join(" ")
      outlog "#{indent} dir/* = #{files}"
    end
#   outlog "#{indent} livetext params = #{livedata.inpect} " unless livedata.nil?
    outlog 
    $log.close
    $log = File.new("/tmp/runeblog.log","a")
  end

end

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
runeblog-0.3.28 lib/logging.rb
runeblog-0.3.27 lib/logging.rb
runeblog-0.3.26 lib/logging.rb
runeblog-0.3.25 lib/logging.rb
runeblog-0.3.24 lib/logging.rb
runeblog-0.3.23 lib/logging.rb
runeblog-0.3.22 lib/logging.rb
runeblog-0.3.21 lib/logging.rb
runeblog-0.3.20 lib/logging.rb
runeblog-0.3.19 lib/logging.rb
runeblog-0.3.18 lib/logging.rb
runeblog-0.3.17 lib/logging.rb
runeblog-0.3.16 lib/logging.rb
runeblog-0.3.15 lib/logging.rb
runeblog-0.3.14 lib/logging.rb
runeblog-0.3.13 lib/logging.rb
runeblog-0.3.12 lib/logging.rb
runeblog-0.3.11 lib/logging.rb
runeblog-0.3.10 lib/logging.rb
runeblog-0.3.08 lib/logging.rb