Class: Rubee::Stdout
- Inherits:
-
Object
- Object
- Rubee::Stdout
- Defined in:
- lib/rubee/logger.rb
Class Method Summary collapse
- .critical(message:, **options, &block) ⇒ Object
- .debug(object:, **options, &block) ⇒ Object
- .error(message:, **options, &block) ⇒ Object
- .info(message:, **options, &block) ⇒ Object
- .log(severity, message, options = {}, &block) ⇒ Object
- .print_critical(message) ⇒ Object
- .print_debug(message) ⇒ Object
- .print_error(message) ⇒ Object
- .print_info(message) ⇒ Object
- .print_warn(message) ⇒ Object
- .warn(message:, **options, &block) ⇒ Object
Class Method Details
.critical(message:, **options, &block) ⇒ Object
40 41 42 |
# File 'lib/rubee/logger.rb', line 40 def critical(message:, **, &block) log(:critical, , , &block) end |
.debug(object:, **options, &block) ⇒ Object
48 49 50 |
# File 'lib/rubee/logger.rb', line 48 def debug(object:, **, &block) log(:debug, object.inspect, , &block) end |
.error(message:, **options, &block) ⇒ Object
36 37 38 |
# File 'lib/rubee/logger.rb', line 36 def error(message:, **, &block) log(:error, , , &block) end |
.info(message:, **options, &block) ⇒ Object
44 45 46 |
# File 'lib/rubee/logger.rb', line 44 def info(message:, **, &block) log(:info, , , &block) end |
.log(severity, message, options = {}, &block) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/rubee/logger.rb', line 72 def log(severity, , = {}, &block) time = Time.now.strftime('%Y-%m-%d %H:%M:%S') if .any? = .map { |k, v| "[#{k}: #{v}]" }.join << " #{}" end send("print_#{severity}", "[#{time}] #{severity.upcase} #{}") block&.call(, ) if block_given? end |
.print_critical(message) ⇒ Object
68 69 70 |
# File 'lib/rubee/logger.rb', line 68 def print_critical() color_puts(, color: :red, style: :blink) end |
.print_debug(message) ⇒ Object
64 65 66 |
# File 'lib/rubee/logger.rb', line 64 def print_debug() color_puts() end |
.print_error(message) ⇒ Object
52 53 54 |
# File 'lib/rubee/logger.rb', line 52 def print_error() color_puts(, color: :red) end |
.print_info(message) ⇒ Object
56 57 58 |
# File 'lib/rubee/logger.rb', line 56 def print_info() color_puts(, color: :gray) end |
.print_warn(message) ⇒ Object
60 61 62 |
# File 'lib/rubee/logger.rb', line 60 def print_warn() color_puts(, color: :yellow) end |
.warn(message:, **options, &block) ⇒ Object
32 33 34 |
# File 'lib/rubee/logger.rb', line 32 def warn(message:, **, &block) log(:warn, , , &block) end |