Module: OnlyofficeLoggerHelper
- Defined in:
- lib/onlyoffice_logger_helper/logger_helper.rb,
lib/onlyoffice_logger_helper/version.rb
Overview
Module for output stuff in console
Constant Summary collapse
- NAME =
Returns name of gem.
'onlyoffice_logger_helper'
- VERSION =
Returns version of gem.
'1.3.0'
- GREEN_COLOR_CODE =
Green color code
32
- RED_COLOR_CODE =
Red color code
31
Class Method Summary collapse
-
.colorize(text, color_code) ⇒ Object
Add color code to text.
-
.green_log(entry) ⇒ void
Colorize log in green.
-
.log(entry, color_code = nil) ⇒ Object
Output log entry to terminal.
-
.red_log(entry) ⇒ void
Colorize log in red.
-
.sleep_and_log(reason, seconds) ⇒ void
Sleep for some time and output log.
Class Method Details
.colorize(text, color_code) ⇒ Object
Add color code to text
23 24 25 |
# File 'lib/onlyoffice_logger_helper/logger_helper.rb', line 23 def self.colorize(text, color_code) "\e[#{color_code}m#{text}\e[0m" end |
.green_log(entry) ⇒ void
This method returns an undefined value.
Colorize log in green
30 31 32 |
# File 'lib/onlyoffice_logger_helper/logger_helper.rb', line 30 def self.green_log(entry) log(entry, GREEN_COLOR_CODE) end |
.log(entry, color_code = nil) ⇒ Object
Output log entry to terminal
13 14 15 16 17 18 |
# File 'lib/onlyoffice_logger_helper/logger_helper.rb', line 13 def self.log(entry, color_code = nil) caller_name = caller(1..1).first.to_s[/\w+.rb/].chomp('.rb') time_stamp = Time.now.strftime('%T/%d.%m.%y') = "#{time_stamp} [#{caller_name}] #{entry}" color_code ? puts(colorize(, color_code)) : puts() end |
.red_log(entry) ⇒ void
This method returns an undefined value.
Colorize log in red
37 38 39 |
# File 'lib/onlyoffice_logger_helper/logger_helper.rb', line 37 def self.red_log(entry) log(entry, RED_COLOR_CODE) end |
.sleep_and_log(reason, seconds) ⇒ void
This method returns an undefined value.
Sleep for some time and output log
45 46 47 48 49 |
# File 'lib/onlyoffice_logger_helper/logger_helper.rb', line 45 def self.sleep_and_log(reason, seconds) log("Start sleeping for #{seconds} seconds because of `#{reason}`") sleep(seconds) log("Stopped sleeping for #{seconds} seconds because of `#{reason}`") end |