Class: CliApplication::Log::File
- Defined in:
- lib/cli_application/log/file.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#folder ⇒ Object
readonly
Returns the value of attribute folder.
Instance Method Summary collapse
-
#initialize(app, log, class_folder) ⇒ File
constructor
A new instance of File.
- #log(message) ⇒ Object
- #save_app_finish_information ⇒ Object
- #save_app_run_information ⇒ Object
- #save_app_start_information ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(app, log, class_folder) ⇒ File
Returns a new instance of File.
7 8 9 10 11 12 |
# File 'lib/cli_application/log/file.rb', line 7 def initialize(app, log, class_folder) @app = app @log = log @class_folder = class_folder init_log end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
5 6 7 |
# File 'lib/cli_application/log/file.rb', line 5 def filename @filename end |
#folder ⇒ Object (readonly)
Returns the value of attribute folder.
4 5 6 |
# File 'lib/cli_application/log/file.rb', line 4 def folder @folder end |
Instance Method Details
#log(message) ⇒ Object
38 39 40 41 |
# File 'lib/cli_application/log/file.rb', line 38 def log() ::File.open(@filename, 'a') {|f| f.write + "\n" } ::File.chmod(0777, @filename) end |
#save_app_finish_information ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cli_application/log/file.rb', line 27 def save_app_finish_information log(I18n.t('config.log_section.finish_header')) unless @exception.nil? log(@exception.) log(@exception.backtrace.join("\n")) end log(I18n.t('config.log_section.app_executed_at', time: Time.zone.now, executed_at: @app.executed_at.round(3))) log(I18n.t('config.log_section.app_memory', value: StTools::Human.memory)) log(I18n.t('config.log_section.app_exitcode', exitcode: @app.exitcode, status: ((@app.exitcode == 0 ? 'SUCCESS' : 'FAIL')))) end |
#save_app_run_information ⇒ Object
22 23 24 25 |
# File 'lib/cli_application/log/file.rb', line 22 def save_app_run_information log(I18n.t('config.log_section.run_header')) log("") end |
#save_app_start_information ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/cli_application/log/file.rb', line 14 def save_app_start_information log(I18n.t('config.log_section.start_header')) log(I18n.t('config.log_section.app_name', name: $PROGRAM_NAME)) log(I18n.t('config.log_section.app_script_name', name: ::File.basename($PROGRAM_NAME))) log(I18n.t('config.log_section.app_started_at', time: Time.zone.now)) log("") end |