Module: RuneRb::System::Log

Overview

Since:

  • 0.9.3

Instance Method Summary collapse

Instance Method Details

#class_nameObject

Gets this class' name.

Since:

  • 0.9.3


3
4
5
# File 'app/system/log.rb', line 3

def class_name
  self.class.name.split('::').last.to_sym
end

#err(*lines) ⇒ Object

Log error lines

Parameters:

  • lines (Array)

    lines of text that are passed to the logger.

Since:

  • 0.9.3


34
35
36
37
38
39
40
# File 'app/system/log.rb', line 34

def err(*lines)
  lines.each do |line|
    RuneRb::GLOBAL[:LOG_FILE].error(RuneRb::GLOBAL[:COLOR].strip("[#{Time.now.strftime('[%H:%M')}] #{line}"))
    RuneRb::GLOBAL[:LOG].error(RuneRb::GLOBAL[:COLOR].magenta.bold("[#{class_name}] ~> #{line}"))
  end
  nil
end

#err!(*lines) ⇒ Object

Log fatal lines

Parameters:

  • lines (Array)

    lines of text that are passed to the logger.

Since:

  • 0.9.3


45
46
47
48
49
50
51
# File 'app/system/log.rb', line 45

def err!(*lines)
  lines.each do |line|
    RuneRb::GLOBAL[:LOG_FILE].fatal(RuneRb::GLOBAL[:COLOR].strip("[#{Time.now.strftime('[%H:%M')}] #{line}"))
    RuneRb::GLOBAL[:LOG].error(RuneRb::GLOBAL[:COLOR].red.bold("[#{class_name}] ~> #{line}"))
  end
  nil
end

#log(*lines) ⇒ Object

Log info lines

Parameters:

  • lines (Array)

    lines of text that are passed to the logger.

Since:

  • 0.9.3


10
11
12
13
14
15
16
# File 'app/system/log.rb', line 10

def log(*lines)
  lines.each do |line|
    RuneRb::GLOBAL[:LOG_FILE].info(RuneRb::GLOBAL[:COLOR].strip("[#{Time.now.strftime('[%H:%M')}] #{line}"))
    RuneRb::GLOBAL[:LOG].info(RuneRb::GLOBAL[:COLOR].white("[#{class_name}] -> #{line}"))
  end
  nil
end

#log!(*lines) ⇒ Object Also known as: debug

Log warning lines

Parameters:

  • lines (Array)

    lines of text that are passed to the logger.

Since:

  • 0.9.3


21
22
23
24
25
26
27
# File 'app/system/log.rb', line 21

def log!(*lines)
  lines.each do |line|
    RuneRb::GLOBAL[:LOG_FILE].warn(RuneRb::GLOBAL[:COLOR].strip("[#{Time.now.strftime('[%H:%M')}] #{line}"))
    RuneRb::GLOBAL[:LOG].warn(RuneRb::GLOBAL[:COLOR].yellow("[#{class_name}] -> #{line}"))
  end
  nil
end

#symbolize_file(string) ⇒ Object

Returns the file name as a symbol.

Parameters:

  • string (String)

    The path to the file.

Since:

  • 0.9.3


55
56
57
# File 'app/system/log.rb', line 55

def symbolize_file(string)
  File.basename(string, '*.rb').to_sym
end