Class: RailsSemanticLogging::RSpec::InMemoryAppender

Inherits:
SemanticLogger::Subscriber
  • Object
show all
Defined in:
lib/rails_semantic_logging/rspec/matchers.rb

Overview

In-memory appender that collects log entries for assertion

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInMemoryAppender

Returns a new instance of InMemoryAppender.



11
12
13
14
# File 'lib/rails_semantic_logging/rspec/matchers.rb', line 11

def initialize
  super(level: :trace)
  @logs = []
end

Instance Attribute Details

#logsObject (readonly)

Returns the value of attribute logs.



9
10
11
# File 'lib/rails_semantic_logging/rspec/matchers.rb', line 9

def logs
  @logs
end

Instance Method Details

#flushObject



20
21
22
# File 'lib/rails_semantic_logging/rspec/matchers.rb', line 20

def flush
  # No-op for in-memory
end

#log(log_entry) ⇒ Object



16
17
18
# File 'lib/rails_semantic_logging/rspec/matchers.rb', line 16

def log(log_entry)
  @logs << log_entry
end