Class: Logger
Overview
Display and log project messages
Class Method Summary collapse
-
.close ⇒ Object
Close Log file.
-
.create(project) ⇒ Object
Create or reset logfile.
-
.verbose(msg) ⇒ Object
Display and log text.
-
.verboseln(msg) ⇒ Object
Display and log text line.
Instance Method Summary collapse
-
#initialize ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize ⇒ Logger
Returns a new instance of Logger.
10 11 12 |
# File 'lib/asker/logger.rb', line 10 def initialize @logfile = null end |
Class Method Details
.close ⇒ Object
Close Log file
42 43 44 |
# File 'lib/asker/logger.rb', line 42 def self.close @logfile.close end |
.create(project) ⇒ Object
Create or reset logfile
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/asker/logger.rb', line 29 def self.create(project) @logfile = File.open(project.get(:logpath), 'w') @logfile.write('=' * 50 + "\n") @logfile.write("Created by : #{Application::NAME}") @logfile.write(" (version #{Application::VERSION})\n") @logfile.write("File : #{project.get(:logname)}\n") @logfile.write("Time : #{Time.new}\n") @logfile.write("Author : David Vargas Ruiz\n") @logfile.write('=' * 50 + "\n\n") end |
.verbose(msg) ⇒ Object
Display and log text
16 17 18 19 |
# File 'lib/asker/logger.rb', line 16 def self.verbose(msg) print msg if Application.instance.config['global']['verbose'] == 'yes' @logfile&.write(msg) end |
.verboseln(msg) ⇒ Object
Display and log text line
23 24 25 |
# File 'lib/asker/logger.rb', line 23 def self.verboseln(msg) verbose(msg + "\n") end |