Class: Mnemosyne::Logger
- Inherits:
-
Object
- Object
- Mnemosyne::Logger
- Defined in:
- lib/mnemosyne/logger.rb
Instance Method Summary collapse
-
#initialize(allowed_log_levels) ⇒ Logger
constructor
A new instance of Logger.
- #log(message, type = :info) ⇒ Object
Constructor Details
#initialize(allowed_log_levels) ⇒ Logger
Returns a new instance of Logger.
4 5 6 |
# File 'lib/mnemosyne/logger.rb', line 4 def initialize(allowed_log_levels) @allowed_log_levels = allowed_log_levels end |
Instance Method Details
#log(message, type = :info) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/mnemosyne/logger.rb', line 8 def log(, type=:info) return unless @allowed_log_levels.include?(type.to_s) time = Time.now.strftime("%Y-%m-%d %H:%M:%S") case type when :info puts "[#{time}] [INF]:#{}".colorize(:light_blue) when :success puts "[#{time}] [SUC]:#{}".colorize(:green) when :error puts "[#{time}] [ERR]:#{}".colorize(:red) when :warn puts "[#{time}] [WAR]:#{}".colorize(:yellow) else puts "[#{type.upcase}] [#{time}] #{}" end end |