Class: Aspector::Logger
- Inherits:
-
Object
- Object
- Aspector::Logger
- Defined in:
- lib/aspector/logger.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#level ⇒ Object
Returns the value of attribute level.
Instance Method Summary collapse
-
#initialize(context) ⇒ Logger
constructor
A new instance of Logger.
- #log(level, *args) ⇒ Object
- #visible?(level) ⇒ Boolean
Constructor Details
#initialize(context) ⇒ Logger
Returns a new instance of Logger.
7 8 9 10 11 12 13 14 15 |
# File 'lib/aspector/logger.rb', line 7 def initialize context @context = context if (level_string = ENV['ASPECTOR_LOG_LEVEL']) @level = string_to_level(level_string) else @level = Logging::DEFAULT_VISIBLE_LEVEL end end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
4 5 6 |
# File 'lib/aspector/logger.rb', line 4 def context @context end |
#level ⇒ Object
Returns the value of attribute level.
5 6 7 |
# File 'lib/aspector/logger.rb', line 5 def level @level end |
Instance Method Details
#log(level, *args) ⇒ Object
17 18 19 20 21 |
# File 'lib/aspector/logger.rb', line 17 def log level, *args return if self.level > level puts log_prefix(level) << args.join(" | ") end |
#visible?(level) ⇒ Boolean
23 24 25 |
# File 'lib/aspector/logger.rb', line 23 def visible? level self.level <= level end |