Problem/Motivation

With a link having a host that cannot be resolved and by running drush cron, the console outputs:

[error] Unhandled link error https://this.host.cannot.be.resolved.com has been found: cURL error 6: Could not resolve host: this.host.cannot.be.resolved.com (see https://curl.se/libcurl/c/libcurl-errors.html) for https://this.host.cannot.be.resolved.com."

The link correctly marked as being broken but logging such a message looks very depressing. It makes you think that the cron process was interrupted and didn't complete. As the scope was fulfilled, i.e., the link was correctly marked as broken, what's the purpose of filling the logs with such messages?

If cURL returned an exception while checking the link it's exactly what it’s supposed to do. It's just fulfilling its mission. It's a success, not an error.

Linkchecker:
You've asked me to detect broken links, I just did and caught this one, whose host cannot be solved. Do I earn a bonus?.
Developer:
No. We consider this an error. Shame on you

Steps to reproduce

  1. Add a link with unsolvable host
  2. Rebuild list
  3. Run cron with Drush

Proposed resolution

Do not log such errors in \Drupal\linkchecker\LinkCheckerService::exceptionHandling() by default. They were caught and addressed. This should be enough, avoid flooding the logs with unnecessary entries that are only confusing the site builder.

User interface changes

New config option to toggle logging exception messages.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes

joelpittet made their first commit to this issue’s fork.

joelpittet’s picture

Issue summary: View changes

I agree with this message (after getting some coffee in me ☕) but I think when debugging that detailed logging can be handy. So the default should be to silence them but keep that detail when someone asks for it explicitly.

Tweaked the issue summary to that end.

joelpittet’s picture

Status: Active » Needs review

The MR tackles both statusHandling and exceptionHandling. Can you have peek @claudiu.cristea
and see if that makes this "track" better in your mind? I have been thinking similar things for ages but didn't put it into an issue as well as you.

joelpittet’s picture

joelpittet’s picture

Issue tags: +Needs manual testing

AI assisted: I reviewed the output and sent it on a few iterations. Read all the messages, but didn't yet visually see where it put the checkbox. I will apply this in production and see.

joelpittet’s picture

StatusFileSize
new87.69 KB

The two of these might be confusing:
config ui

But the error logs have never been so clean!

claudiu.cristea’s picture

The MR looks good. I still think we should not log at all. I will leave it at your discretion if we keep it configurable or just remove it.

Re #11: Maybe we can insert the word "debug". E.g., "Debug link check exceptions". I don't see the value of this logging maybe only for debugging purposes. EDIT: In this case we might want to log them to the "debug" channel level?

joelpittet’s picture

RE #12 Yes, debug channel and wording is better here. The current solution of having a second checkbox seems most correct to me, but I am hesitating because under "Log level" there is a "debug" option. And I don't want to confuse, especially if the default "all" doesn't mean "all + debug" it still would cause me to be confused.

joelpittet’s picture

Re #12/#13: Went with debug severity and no separate checkbox. Both "Unhandled link error" messages now log at RfcLogLevel::DEBUG, so they're silent at the default log level and appear when "Log level" is set to "Debug messages". Nothing else in linkchecker logs at debug, so that option finally does something.

I also relabeled "All messages (default)" to "Informational and above (default)", since it never included debug.

That should cover both the worry I had about the confusing UI and go in the direction of "don't log it at all"

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Thank you. I've tested manually, it looks good now also in console. I like the new approach, much cleaner.

joelpittet’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs manual testing

Thanks claudiu for the manual testing. The merge train 🚂 has left the station! This will be in the 2.2.0-rc1

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • joelpittet committed 302d4ddb on 2.1.x
    fix: #3625860 Errors messages logged while running cron are confusing...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.