Sha256: 1ca47792ae09e4e8ae41a8d4bbff82fb4985ba2ebadd9a7f41448935c7eeed05
Contents?: true
Size: 963 Bytes
Versions: 4
Compression:
Stored size: 963 Bytes
Contents
module SemanticLogger module Test # Logging class to captures all logging events in memory. # # Example: # # class UserTest < ActiveSupport::TestCase # describe User do # let(:capture_logger) { SemanticLogger::Test::CaptureLogEvents.new } # let(:user) { User.new } # # it "logs message" do # user.stub(:logger, capture_logger) do # user.enable! # end # assert_equal "Hello World", capture_logger.events.last.message # assert_equal :info, capture_logger.events.last.level # end # end # end class CaptureLogEvents < SemanticLogger::Subscriber attr_accessor :events # By default collect all log levels, and collect metric only log events. def initialize(level: :trace, metrics: true) super(level: level, metrics: true) end def log(log) (@events ||= []) << log end end end end
Version data entries
4 entries across 4 versions & 1 rubygems