Skip to content

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

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

Closed
bstrie opened this issue Jun 25, 2013 · 9 comments
Closed

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

bstrie opened this issue Jun 25, 2013 · 9 comments

Comments

@bstrie
Copy link
Contributor

bstrie commented Jun 25, 2013

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.

@thestinger
Copy link
Contributor

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

@bstrie
Copy link
Contributor Author

bstrie commented Jun 26, 2013

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

@brson
Copy link
Contributor

brson commented Jul 10, 2013

It's a wart yeah. Nominating.

@catamorphism
Copy link
Contributor

Sub-bug of #3309. De-nominating

@flaper87
Copy link
Contributor

flaper87 commented Oct 1, 2013

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?

@alexcrichton
Copy link
Member

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

@flaper87
Copy link
Contributor

flaper87 commented Oct 1, 2013

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

@alexcrichton
Copy link
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.

@catamorphism
Copy link
Contributor

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

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 1, 2021
Remove rustfmt bug workaround

The bug is reportedly fixed.

changelog: none
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

No branches or pull requests

6 participants