Skip to content

Multi-Line Log Messages Only Rendering First Line #25

Closed
@tubbo

Description

@tubbo

When a multi-line log message is encountered by this gem, only the first line can be seen in tests:

📜   info  http://127.0.0.1:59998/assets/workarea/storefront/application-661443b5298bc0cfe959b870c0eceb86be72e316ef78fe5b99f8a30dc7fff36b.js 48170:61573
     Error:

I did some digging and discovered that the culprit is this line, where @message is overwritten from the original. This looks like it was just meant to parse out the backtrace so it doesn't spam your test output, but it also seems to be stripping all log lines.

I monkey-patched the removal of that last line in my app, and was able to see the log messages:

class Capybara::Chromedriver::Logger::Message do
  def extract_file_and_location!
    match = message.match(/^(.+)\s+?(\d+:\d+)\s+?(.+)$/)

    return unless match

    _, @file, @location, _message = match.to_a
  end
end

My test output now looks like:

📜   info  http://127.0.0.1:55373/assets/workarea/storefront/application-661443b5298bc0cfe959b870c0eceb86be72e316ef78fe5b99f8a30dc7fff36b.js 48170:61573
     http://127.0.0.1:55373/assets/workarea/storefront/application-661443b5298bc0cfe959b870c0eceb86be72e316ef78fe5b99f8a30dc7fff36b.js 48170:61573 Error:

     ***************** BEGIN aXe AUDIT *****************

     CURRENT PATH: /cart

     VIOLATIONS FOUND: 2

     *****

     VIOLATION #1:
       Severity: serious
       Description: Elements must have sufficient color contrast

     Node: <a class="button" href="/">Continue Shopping</a>

     Fix any of the following:
       Element has insufficient color contrast of 2.3 (foreground color: #ffffff, background color: #ff8e0a, font size: 13.5pt, font weight: bold). Expected contrast ratio of 4.5:1
...

I'm sure there was a pretty good reason for that, and just removing the line that broke things probably isn't the best solution, so I wanted to open a discussion before making a PR or anything to fix it...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions