Class: Util::TxtLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/kuniri/util/txt_logger.rb

Overview

Create log in a text format. This classes handling the correct way of generate the log in a .txt format.

Instance Method Summary collapse

Constructor Details

#initialize(pPath = "/tmp/kuniri.log") ⇒ TxtLogger

Returns a new instance of TxtLogger.

Parameters:

  • pPath (String) (defaults to: "/tmp/kuniri.log")

    Path for save the log. The default is /tmp/



11
12
13
# File 'lib/kuniri/util/txt_logger.rb', line 11

def initialize(pPath = "/tmp/kuniri.log")
  super(pPath)
end

Instance Method Details

#write_log(pMessage) ⇒ Object

Write a message as .txt file.

Parameters:

  • pMessage (String)

    Massage to be write in the log file.



17
18
19
20
21
22
23
# File 'lib/kuniri/util/txt_logger.rb', line 17

def write_log(pMessage)
  File.open(@log_path, 'a') do |file|
    file.write("="*10 + "\n")
    file.write("time: " + Time.now.strftime("%d/%m/%Y %H:%M:%S") + "\n")
    file.write("message: " + pMessage + "\n")
  end
end