Class: Scrubyt::Logger
- Inherits:
-
Object
- Object
- Scrubyt::Logger
- Defined in:
- lib/scrubyt/logging.rb
Overview
Simple logger implementation, based on Scrubyt’s original logging style. Messages will be sent to STDERR. Logging can be limited to certain message levels by specifying them on initialization, e.g.
Scrubyt::Logger.new(:ACTION, :ERROR) # will only log action/error messages
Defined Under Namespace
Classes: Message, MultiLineMessage
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(*levels) ⇒ Logger
constructor
A new instance of Logger.
- #log(level, message) ⇒ Object
Constructor Details
#initialize(*levels) ⇒ Logger
Returns a new instance of Logger.
63 64 65 |
# File 'lib/scrubyt/logging.rb', line 63 def initialize(*levels) @levels = levels end |
Instance Attribute Details
#output_stream ⇒ Object
75 76 77 |
# File 'lib/scrubyt/logging.rb', line 75 def output_stream @output_stream || STDERR end |
Instance Method Details
#log(level, message) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/scrubyt/logging.rb', line 67 def log(level, ) return unless logging?(level) = .is_a?(Array) ? MultiLineMessage : Message output_stream.puts .new(level, ) end |