Class: Navvy::Log
- Inherits:
-
Object
- Object
- Navvy::Log
- Defined in:
- lib/navvy/log.rb
Defined Under Namespace
Classes: LoggerNotFound
Class Attribute Summary collapse
-
.logger ⇒ Symbol?
Default logger.
-
.quiet ⇒ true, false
Be quiet?.
Class Method Summary collapse
-
.info(message, color = nil) ⇒ Object
Pass a log to the logger.
-
.write(logger, message, color = nil) ⇒ Object
Actually write the log to the logger.
Class Attribute Details
.logger ⇒ Symbol?
Default logger
15 16 17 |
# File 'lib/navvy/log.rb', line 15 def self.logger @logger || Navvy.configuration.logger end |
.quiet ⇒ true, false
Be quiet?
24 25 26 |
# File 'lib/navvy/log.rb', line 24 def quiet @quiet end |
Class Method Details
.info(message, color = nil) ⇒ Object
Pass a log to the logger. It will check if self.logger is an array. If it is, it’ll loop through it and log to every logger. If it’s not, it’ll just log once.
output
37 38 39 40 41 42 43 44 45 |
# File 'lib/navvy/log.rb', line 37 def self.info(, color = nil) if logger.is_a? Array logger.each do |logger| write(logger, , color) end else write(logger, , color) end end |
.write(logger, message, color = nil) ⇒ Object
Actually write the log to the logger. It’ll check self.logger and use that to define a logger
output
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/navvy/log.rb', line 56 def self.write(logger, , color = nil) puts "\e[#{color}m#{}\e[0m" unless quiet case logger when :justlogging raise( LoggerNotFound, 'JustLogging could not be found. No logs were created.' ) unless defined? Justlogging.log Justlogging.log() when :rails raise( LoggerNotFound, 'Rails.logger could not be found. No logs were created.' ) unless defined? Rails.logger.info Rails.logger.info() end end |