Skip to content

error!() is too easily conflatable with fail!() #7386

Closed

Description

@bstrie

Before they were both macros, the name of this log level was defensible:

// In days of yore...
log(error, "foo");
fail "foo";

Nowadays, this is a wart in the making:

// Rust Certification Exam, Question 22: how do these differ?
error!("foo");
fail!("foo");

The other log level macros (info, warn, and debug) are fine. I really don't care what we replace error with, though I propose alert! if nobody has any sublime suggestions.

Activity

  1. thestinger commented on Jun 25, 2013

    @thestinger
    Contributor

    How about using log!(level, "message")?

  2. bstrie commented on Jun 26, 2013

    @bstrie
    ContributorAuthor

    Making log into a macro (...again...) would solve our earlier problem of needing to have info, error, warn, and debug as pervasive constants. It would also allow people to use log to name their own variables, as so many people requested.

    Assuming that error! is the most common macro, we could also simply make log!("foo") the same as log!(error, "foo").

  3. brson commented on Jul 10, 2013

    @brson
    Contributor

    It's a wart yeah. Nominating.

  4. catamorphism commented on Sep 5, 2013

    @catamorphism
    Contributor

    Sub-bug of #3309. De-nominating

  5. flaper87 commented on Oct 1, 2013

    @flaper87
    Contributor

    Going back to log(level, msg) makes sense to me, I'm not sure about making log(msg) the same as log!(error, msg), I'd make info the default level instead. Thoughts?

  6. alexcrichton commented on Oct 1, 2013

    @alexcrichton
    Member

    Nominating for backwards-compatible, error logging is something that while not used often should still be used occasionally.

  7. flaper87 commented on Oct 1, 2013

    @flaper87
    Contributor

    Actually, Thinking about this a bit further and looking at 20ab30fc583baeb87bb58bb369e97003a76a8a10 I think error! is fine and having the 4 of them makes more sense. What about changing fail! instead?

    Some ideas: exit, die, raise

  8. alexcrichton commented on Oct 6, 2013

    @alexcrichton
    Member

    After doing a bit of research on this, I disagree with renaming error! to anything else. The debug/info/warn/error log levels appear to be standard across pretty much all implementations/explanations that I could find:

    And that was just for an immediate search of "error log level". If at all it seems that we're missing the fatal! and trace! log levels (although I'm not so sure about trace!).

    In my opinion, the stackoverflow answer to what the log levels mean is a good summary of what each one is and specifically why error! shouldn't fail/die. I think that the fix for this issue should be better documentation about core macros rather than renaming them.

  9. catamorphism commented on Oct 6, 2013

    @catamorphism
    Contributor

    I agree with @alexcrichton . In the interest of avoiding gratuitous code churn, I'm closing this.

  10. added a commit that references this issue on Jul 1, 2021
  11. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions