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

crate name in log map is taken from name of output binary, not the crate name #3346

Closed
jesse99 opened this issue Sep 1, 2012 · 8 comments
Closed
Labels
A-linkage Area: linking into static, shared libraries and binaries E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@jesse99
Copy link
Contributor

jesse99 commented Sep 1, 2012

I can only get error level logging using the project below, I've tried a bunch of versions of RUST_LOG that I think should work and none do (which is complicated by the fact that rustc --ls is still broken). I've tried:

RUST_LOG=logging2::crate::logging2=3
RUST_LOG=::logging2=3
RUST_LOG=3

and more.

Makefile:

RUSTC ?= rustc

dummy1 := $(shell mkdir bin 2> /dev/null)

check:
    $(RUSTC) -o bin/test-logging2 --test crate.rc
    export RUST_LOG=logging2::crate::logging2=3 && ./bin/test-logging2

clean:
    rm -rf bin

crate.rc:

use std;

#[link(name = "logging2",
       vers = "0.1",
       uuid = "91E62841-B9F3-4721-97C6-621BEEE2DA1B")]

mod logging2;

logging2.rs:


#[test]
fn test_logging()
{
    error!("error level");
    warn!("warn level");
    info!("info level");
}

This was with a rustc from master on Sep 1, 2012. Note that I was able to get logging working when compiling a stand-alone rs file.

@brson
Copy link
Contributor

brson commented Sep 1, 2012

This works with RUST_LOG=test-logging2 (the name of the output binary). I'd say this is a bug and we should be using the actual name of the crate.

@jesse99
Copy link
Contributor Author

jesse99 commented Sep 2, 2012

Note that 10.0.4 of the reference manual says that the crate name is from the link attribute.

@graydon
Copy link
Contributor

graydon commented Mar 22, 2013

non-critical for 0.6, de-milestoning

@catamorphism
Copy link
Contributor

Nominating for milestone 5, production-ready. With the new version of rustpkg, the crate name doesn't have to be explicitly specified in a link attribute, so that should be taken into account too (in the absence of an explicit crate name, the crate name for logging purposes should be what-rustpkg-would-infer).

@graydon
Copy link
Contributor

graydon commented Jun 20, 2013

sub-bug of #3309

@graydon
Copy link
Contributor

graydon commented Jun 20, 2013

accepted for production-ready milestone

@pnkfelix
Copy link
Member

visiting for triage, email from 2013 sep 23.

@alexcrichton
Copy link
Member

This is actually currently implemented. The test case above has the attribute not as a crate attribute. The #[link] above is placed on the mod instead of on the crate because of the missing semicolon at the end, and it wouldn't be a crate attribute if it were after the use std; anyway.

Regardless, we do actually use the crate name specified in link attributes as the prefix for logging (maybe this changed between then and now). Closing.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Mar 3, 2024
Add -Zmiri-track-alloc-accesses to readme and fix its wording

I forgot that yesterday...
jaisnan pushed a commit to jaisnan/rust-dev that referenced this issue Jul 29, 2024
Update Rust toolchain from nightly-2024-07-15 to nightly-2024-07-16
without any other source changes.
This is an automatically generated pull request. If any of the CI checks
fail, manual intervention is required. In such a case, review the
changes at https://github.com/rust-lang/rust from
rust-lang@d9284af
up to
rust-lang@24d2ac0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries 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