@@ -3626,30 +3626,51 @@ communication facilities.
3626
3626
3627
3627
The runtime contains a system for directing logging expressions to a logging
3628
3628
console and/or internal logging buffers. @xref {Ref.Expr.Log }. Logging
3629
- expressions can be enabled or disabled via a two-dimensional filtering process:
3629
+ expressions can be enabled per module.
3630
+
3631
+ Logging output is enabled by setting the @code {RUST_LOG } environment variable.
3632
+ @code {RUST_LOG } accepts a logging specification that is a comma-separated list
3633
+ of paths. For each module containing log statements, if @code {RUST_LOG }
3634
+ contains the path to that module or a parent of that module, then its logs
3635
+ will be output to the console. The path to an module consists of the crate
3636
+ name, any parent modules, then the module itself, all separated by double
3637
+ colons (@code {:: }).
3638
+
3639
+ As an example, to see all the logs generated by the compiler, you would set
3640
+ @code {RUST_LOG } to @code {rustc }, which is the crate name (as specified in its
3641
+ @code {link } attribute). @xref {Ref.Comp.Crate }. To narrow down the logs to
3642
+ just crate resolution, you would set it to @code {rustc::metadata::creader }.
3643
+
3644
+ Note that when compiling either .rs or .rc files that don't specifiy a crate
3645
+ name the crate is given a default name that matches the source file, sans
3646
+ extension. In that case, to turn on logging for a program compiled from, e.g.
3647
+ helloworld.rs, @code {RUST_LOG } should be set to @code {helloworld }.
3648
+
3649
+ As a convenience, the logging spec can also be set to a special psuedo-crate,
3650
+ @code {::help }. In this case, when the application starts, the runtime will
3651
+ simply output a list of loaded modules containing log statements, then exit.
3652
+
3653
+ The Rust runtime itself generates logging information. The runtime's logs are
3654
+ generated for a number of artificial modules in the @code {::rt } psuedo-crate,
3655
+ and can be enabled just like the logs for any standard module. The full list
3656
+ of runtime logging modules follows.
3630
3657
3631
3658
@itemize
3632
-
3633
- @sp 1
3634
- @item
3635
- By Item
3636
-
3637
- Each @emph {item } (module, function, iterator, object, type) in Rust has a
3638
- static path within its crate module, and can have logging enabled or
3639
- disabled on a path-prefix basis.
3640
-
3641
- @sp 1
3642
- @item
3643
- By Task
3644
-
3645
- Each @emph {task } in a running Rust program has a unique ownership relation
3646
- through the task ownership tree, and can have logging enabled or disabled on
3647
- an ownership-ancestry basis.
3659
+ @item @code {::rt::mem } Memory management
3660
+ @item @code {::rt::comm } Messaging and task communication
3661
+ @item @code {::rt::task } Task management
3662
+ @item @code {::rt::dom } Task scheduling
3663
+ @item @code {::rt::trace } Unused
3664
+ @item @code {::rt::cache } Type descriptor cache
3665
+ @item @code {::rt::upcall } Compiler-generated runtime calls
3666
+ @item @code {::rt::timer } The scheduler timer
3667
+ @item @code {::rt::gc } Garbage collection
3668
+ @item @code {::rt::stdlib } Functions used directly by the standard library
3669
+ @item @code {::rt::kern } The runtime kernel
3670
+ @item @code {::rt::backtrace } Unused
3671
+ @item @code {::rt::callback } Unused
3648
3672
@end itemize
3649
3673
3650
- Logging is integrated into the language for efficiency reasons, as well as the
3651
- need to filter logs based on these two built-in dimensions.
3652
-
3653
3674
@node Ref.Run.Sig
3654
3675
@subsection Ref.Run.Sig
3655
3676
@c * Ref.Run.Sig:: Runtime signal handler.
0 commit comments