Method: Console::Capture#call
- Defined in:
- lib/console/capture.rb
#call(subject = nil, *arguments, severity: UNKNOWN, event: nil, **options, &block) ⇒ Object
Record a log message in the buffer.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/console/capture.rb', line 88 def call(subject = nil, *arguments, severity: UNKNOWN, event: nil, **, &block) record = { time: ::Time.now.iso8601, severity: severity, **, } if subject record[:subject] = subject end if event record[:event] = event.to_hash end if arguments.any? record[:arguments] = arguments end if annotation = Fiber.current.annotation record[:annotation] = annotation end if block_given? if block.arity.zero? record[:message] = yield else buffer = StringIO.new yield buffer record[:message] = buffer.string end else record[:message] = arguments.join(" ") end @records << record end |