Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-Line Log Messages Only Rendering First Line #25

Closed
tubbo opened this issue Oct 1, 2020 · 2 comments · May be fixed by #32
Closed

Multi-Line Log Messages Only Rendering First Line #25

tubbo opened this issue Oct 1, 2020 · 2 comments · May be fixed by #32

Comments

@tubbo
Copy link

tubbo commented Oct 1, 2020

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...

@dbalatero
Copy link
Owner

I think it's just an oversight on my part. Rather than remove the line, we should enable multiline regexes with the /m flag:

message.match(/^(.+)\s+?(\d+:\d+)\s+?(.+)$/m)

Can you try that, and if it works well, submit a patch? Thanks!

@tubbo
Copy link
Author

tubbo commented Oct 3, 2020

Will do!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants