Skip to content

Commit 55e29ef

Browse files
committed
Mention lazy evaluation of log arguments in tutorial
1 parent 03d9d62 commit 55e29ef

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

doc/tutorial.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,8 @@ top-level module will be called `foo`, and you can set `RUST_LOG` to
729729
`foo` to enable `warn`, `info` and `debug` logging for the module.
730730

731731
Turned-off `log` statements impose minimal overhead on the code that
732-
contains them, so except in code that needs to be really, really fast,
732+
contains them, because the arguments to `log` are evaluated lazily.
733+
So except in code that needs to be really, really fast,
733734
you should feel free to scatter around debug logging statements, and
734735
leave them in.
735736

@@ -743,6 +744,9 @@ and will log the formatted string:
743744
#error("fatal: %s", get_error_string());
744745
~~~~
745746

747+
Because the macros `#debug`, `#warn`, and `#error` expand to calls to `log`,
748+
their arguments are also lazily evaluated.
749+
746750
## Assertions
747751

748752
The keyword `assert`, followed by an expression with boolean type,

0 commit comments

Comments
 (0)