Skip to content

Commit 84bd6bb

Browse files
committed
logging is an external crate
1 parent 68b8901 commit 84bd6bb

File tree

1 file changed

+0
-58
lines changed

1 file changed

+0
-58
lines changed

src/doc/reference.md

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4243,64 +4243,6 @@ In general, `--crate-type=bin` or `--crate-type=lib` should be sufficient for
42434243
all compilation needs, and the other options are just available if more
42444244
fine-grained control is desired over the output format of a Rust crate.
42454245

4246-
### Logging system
4247-
4248-
The runtime contains a system for directing [logging
4249-
expressions](#logging-expressions) to a logging console and/or internal logging
4250-
buffers. Logging can be enabled per module.
4251-
4252-
Logging output is enabled by setting the `RUST_LOG` environment variable.
4253-
`RUST_LOG` accepts a logging specification made up of a comma-separated list of
4254-
paths, with optional log levels. For each module containing log expressions, if
4255-
`RUST_LOG` contains the path to that module or a parent of that module, then
4256-
logs of the appropriate level will be output to the console.
4257-
4258-
The path to a module consists of the crate name, any parent modules, then the
4259-
module itself, all separated by double colons (`::`). The optional log level
4260-
can be appended to the module path with an equals sign (`=`) followed by the
4261-
log level, from 1 to 4, inclusive. Level 1 is the error level, 2 is warning, 3
4262-
info, and 4 debug. You can also use the symbolic constants `error`, `warn`,
4263-
`info`, and `debug`. Any logs less than or equal to the specified level will
4264-
be output. If not specified then log level 4 is assumed. Debug messages can be
4265-
omitted by passing `--cfg ndebug` to `rustc`.
4266-
4267-
As an example, to see all the logs generated by the compiler, you would set
4268-
`RUST_LOG` to `rustc`, which is the crate name (as specified in its `crate_id`
4269-
[attribute](#attributes)). To narrow down the logs to just crate resolution,
4270-
you would set it to `rustc::metadata::creader`. To see just error logging use
4271-
`rustc=0`.
4272-
4273-
Note that when compiling source files that don't specify a crate name the crate
4274-
is given a default name that matches the source file, with the extension
4275-
removed. In that case, to turn on logging for a program compiled from, e.g.
4276-
`helloworld.rs`, `RUST_LOG` should be set to `helloworld`.
4277-
4278-
#### Logging Expressions
4279-
4280-
Rust provides several macros to log information. Here's a simple Rust program
4281-
that demonstrates all four of them:
4282-
4283-
```
4284-
#![feature(phase)]
4285-
#[phase(plugin, link)] extern crate log;
4286-
4287-
fn main() {
4288-
error!("This is an error log")
4289-
warn!("This is a warn log")
4290-
info!("this is an info log")
4291-
debug!("This is a debug log")
4292-
}
4293-
```
4294-
4295-
These four log levels correspond to levels 1-4, as controlled by `RUST_LOG`:
4296-
4297-
```sh
4298-
$ RUST_LOG=rust=3 ./rust
4299-
This is an error log
4300-
This is a warn log
4301-
this is an info log
4302-
```
4303-
43044246
# Appendix: Rationales and design tradeoffs
43054247

43064248
*TODO*.

0 commit comments

Comments
 (0)