Class: RSpecTracer::Logger Private
- Inherits:
-
Object
- Object
- RSpecTracer::Logger
- Defined in:
- lib/rspec_tracer/logger.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Internal Logger — see RSpecTracer for the user-facing surface.
Internal logger; thin wrapper around IO#puts gated on numeric
log level. Exposed via RSpecTracer.logger.
Class Attribute Summary collapse
-
.default_out ⇒ IO?
private
Process-wide default destination for loggers constructed without an explicit
out:.
Instance Method Summary collapse
-
#debug(message) ⇒ Object
private
Internal method on the tracer pipeline.
-
#error(message) ⇒ Object
private
Internal method on the tracer pipeline.
-
#info(message) ⇒ Object
private
Internal method on the tracer pipeline.
-
#initialize(log_level, out: nil) ⇒ Logger
constructor
private
A new instance of Logger.
-
#warn(message) ⇒ Object
private
Internal method on the tracer pipeline.
Constructor Details
#initialize(log_level, out: nil) ⇒ Logger
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Logger.
30 31 32 33 |
# File 'lib/rspec_tracer/logger.rb', line 30 def initialize(log_level, out: nil) @log_level = log_level @out = out || self.class.default_out || $stdout end |
Class Attribute Details
.default_out ⇒ IO?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Process-wide default destination for loggers constructed
without an explicit out:. nil (the norm) means $stdout,
which normal rspec runs rely on. The rspec-tracer binary
sets this to its stderr BEFORE booting the tracer library, so
loggers constructed while the project's .rspec-tracer config
loads (e.g. by the 1.x deprecation shims, or recreated after a
config log_level call resets the memoized instance) already
bind to stderr and machine-readable stdout (blast-radius --json) stays free of diagnostics. See CLI.
23 24 25 |
# File 'lib/rspec_tracer/logger.rb', line 23 def default_out @default_out end |
Instance Method Details
#debug(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
37 38 39 |
# File 'lib/rspec_tracer/logger.rb', line 37 def debug() @out.puts if @log_level == 1 end |
#error(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
55 56 57 |
# File 'lib/rspec_tracer/logger.rb', line 55 def error() @out.puts if @log_level.between?(1, 4) end |
#info(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
43 44 45 |
# File 'lib/rspec_tracer/logger.rb', line 43 def info() @out.puts if @log_level.between?(1, 2) end |
#warn(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Internal method on the tracer pipeline.
49 50 51 |
# File 'lib/rspec_tracer/logger.rb', line 49 def warn() @out.puts if @log_level.between?(1, 3) end |