mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Mention lazy evaluation of log arguments in tutorial
This commit is contained in:
parent
03d9d6287b
commit
55e29ef4aa
@ -729,7 +729,8 @@ top-level module will be called `foo`, and you can set `RUST_LOG` to
|
||||
`foo` to enable `warn`, `info` and `debug` logging for the module.
|
||||
|
||||
Turned-off `log` statements impose minimal overhead on the code that
|
||||
contains them, so except in code that needs to be really, really fast,
|
||||
contains them, because the arguments to `log` are evaluated lazily.
|
||||
So except in code that needs to be really, really fast,
|
||||
you should feel free to scatter around debug logging statements, and
|
||||
leave them in.
|
||||
|
||||
@ -743,6 +744,9 @@ and will log the formatted string:
|
||||
#error("fatal: %s", get_error_string());
|
||||
~~~~
|
||||
|
||||
Because the macros `#debug`, `#warn`, and `#error` expand to calls to `log`,
|
||||
their arguments are also lazily evaluated.
|
||||
|
||||
## Assertions
|
||||
|
||||
The keyword `assert`, followed by an expression with boolean type,
|
||||
|
Loading…
Reference in New Issue
Block a user