class Anywhere::Logger
Constants
- COLORS
- LEVELS
Attributes
log_level[W]
prefix[RW]
Public Class Methods
mutex()
click to toggle source
# File lib/anywhere/logger.rb, line 27 def mutex @mutex ||= Mutex.new end
new(attributes = {})
click to toggle source
# File lib/anywhere/logger.rb, line 36 def initialize(attributes = {}) @attributes = attributes end
Public Instance Methods
log_level()
click to toggle source
# File lib/anywhere/logger.rb, line 32 def log_level @log_level ||= ::Logger::INFO end
print_with_prefix(message)
click to toggle source
# File lib/anywhere/logger.rb, line 59 def print_with_prefix(message) out = [Time.now.utc.iso8601(6)] if prefix.is_a?(String) out << prefix elsif prefix.respond_to?(:call) out << prefix.call end out << message self.class.mutex.synchronize do stream.puts out.join(" ") end end
stream()
click to toggle source
# File lib/anywhere/logger.rb, line 44 def stream @attributes[:stream] ||= STDOUT end