Skip to content

Rename log_err to print #1087

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
brson opened this issue Oct 28, 2011 · 12 comments
Closed

Rename log_err to print #1087

brson opened this issue Oct 28, 2011 · 12 comments
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Oct 28, 2011

log_err is the most common way to get console output, and is usually used in a way that doesn't reflect it's name. For convenience and to make a better impression for 0.1 we should just rename it to 'print'.

@marijnh
Copy link
Contributor

marijnh commented Oct 28, 2011

I was about to do this (well, I wanted to use echo) a few weeks back (telling people to use log_err in a tutorial makes it obvious how ridiculous the name is) -- but with the extra debugging cruft that log and log_err output (#1088), it really is a logging statement, not a print.

@brson
Copy link
Contributor Author

brson commented Oct 28, 2011

Yeah, I was hoping we could make the logging output prettier too: #1088

@brson
Copy link
Contributor Author

brson commented Oct 28, 2011

Regardless of the approach we take, it would be nice for the sake of hello world for printing to be simple. both log_err and io::stdout().write_line(...) are hideous.

We could also create a print() function and put it directly in std, so users could import std::*; print("hello, world").

But seeing as how log is supposed to be so highly integrated into the language, I do kind of think we should be encouraging log. That said, echo might be a better keyword for logging, so we can reserve print for std.

@marijnh
Copy link
Contributor

marijnh commented Oct 28, 2011

io::stdout().write_line(...)

I recently added std::io::println and std::io::print, for exactly this reason.

@pcwalton
Copy link
Contributor

print may not be best, since as noted on the mailing list print suggests stdout. echo isn't bad; I was thinking show by analogy with Haskell's Show, since it's polymorphic.

@bstrie
Copy link
Contributor

bstrie commented Nov 7, 2011

How about alert, which has analogies to print while avoiding conflation. alert also suggests the more severe level of logging that log_err implies.

@marijnh
Copy link
Contributor

marijnh commented Nov 7, 2011

I like alert.

@kud1ing
Copy link

kud1ing commented Nov 7, 2011

I associate "alert" with "Alert dialog box" which is an immediate in-your-face action.
Also JavaScript uses alert() to display a dialog box.

IMHO printing to STDERR is a different form of notification.
I'd be in favor of "print" which is very common in programming languages.

@pcwalton
Copy link
Contributor

pcwalton commented Nov 7, 2011

+1 for alert.

@brson
Copy link
Contributor Author

brson commented Nov 13, 2011

graydon popped up on the mailing list recently to vote for log levels and prelude-defined constants (err, warn, info, debug)

@graydon
Copy link
Contributor

graydon commented Dec 23, 2011

Phew! Finished this today after an embarrassing run of snapshots and partial-rewrites.

The new scheme is this:

log(*level*, *anything*) is a built-in expression form. Level must be a u32 expression, anything can be anything, just like the old log.

log_err is gone

core::debug, core::info, core::warn and core::error are defined in core (thus available everywhere as debug, info, warn and error) and defined as log levels 3, 2, 1, 0 respectively. So you can write log(info, foo) to get info-level logging of foo.

The macros #debug(f, ...), #info(f, ...), #warn(f, ...) and #error(f, ...) are defined in a synthetic chunk of macro-definition buried in the macro expander file (bad place to put it but it works for now, we can factor it out later) and expand to

log(core::debug, #fmt(f, ...))

and similar depending on the macro you use. So you should wind up writing shorter and pithier logging bits using this, since you get #fmt thrown in for free. Just use #debug("foo: %u, bar: %u", f, b) and you get nice output.

There remains some vestigial bad-word support for the words "log_err" and "log_full" in the last snapshots; those will roll over with the next snapshot and vanish but in the meantime the stage1..3 compilers no longer even know about those words.

Hopefully this is ok!

@graydon graydon closed this as completed Dec 23, 2011
@marijnh
Copy link
Contributor

marijnh commented Dec 23, 2011

Awesome! log_err was really starting to become an eyesore.

celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
* update unwind documentation

Co-authored-by: Adrian Palacios <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-cleanup Category: PRs that clean code up or issues documenting cleanup. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

6 participants