···11+# Logging
22+33+With the environment variables `MDBOOK_LOG` and `CI`, you can control how the
44+preprocessor emits logs and diagnostic information.
55+66+## Output style
77+88+{{#include ../snippets/logging/output-style.md}}
99+1010+## `MDBOOK_LOG`
1111+1212+{{#include ../snippets/logging/env-var.md}}
+37
docs/src/rustdoc-links/logging.md
···11+# Logging
22+33+With the environment variables `MDBOOK_LOG` and `CI`, you can control how the
44+preprocessor emits logs and diagnostic information.
55+66+## Output style
77+88+{{#include ../snippets/logging/output-style.md}}
99+1010+## `MDBOOK_LOG`
1111+1212+{{#include ../snippets/logging/env-var.md}}
1313+1414+## Link report
1515+1616+Upon finishing, the preprocessor can display a list of all supported Rust items it finds
1717+in the book and the URLs generated for each item. The list is sorted alphabetically by
1818+item paths. This can be used to, for example, monitor any changes to the generated links
1919+between builds.
2020+2121+To enable this, add the `link-report=debug` directive to `MDBOOK_LOG`, for example:
2222+`MDBOOK_LOG=info,link-report=debug`.
2323+2424+> [!TIP]
2525+>
2626+> You most likely want to include at least an `info` directive in the variable:
2727+>
2828+> - `MDBOOK_LOG=info,link-report=debug` enables `link-report` on top of existing logs.
2929+> - `MDBOOK_LOG=link-report=debug` will _completely disable_ all other logging,
3030+> including from mdBook itself.
3131+3232+> [!TIP]
3333+>
3434+> The displayed items are deduplicated and do not contain the links' locations within
3535+> the book. To see their locations (in the format of `path:line:column`), enable `debug`
3636+> for the entire preprocessor, for example, `MDBOOK_LOG=info,mdbook_rustdoc_links=debug`
3737+> or `MDBOOK_LOG=debug`.
···11+The `MDBOOK_LOG` environment variable allows you to control the verbosity of logging
22+messages. The same variable also controls [mdBook's logging output][mdbook-init-logger].
33+44+The variable has semantics similar to the commonly seen `RUST_LOG` variable. For
55+example:
66+77+- `MDBOOK_LOG=info` enables logging at the `info` (regular) level. The preprocessor will
88+ emit the same amount of information, including diagnostics, as when the variable is
99+ not set, except graphical output styles are not used (see [above](#output-style)).
1010+1111+- `MDBOOK_LOG=debug` enables `debug` (more verbose) logging.
1212+1313+The variable is supported by `tracing-subscriber`. See
1414+[`EnvFilter`][tracing_subscriber::filter::EnvFilter] for the complete usage info.
1515+1616+> [!NOTE]
1717+>
1818+> mdBook [v0.4.x uses the `RUST_LOG` variable][mdbook-init-logger-v0.4] instead of
1919+> `MDBOOK_LOG`. This preprocessor supports both, with `MDBOOK_LOG` taking precedence.
2020+2121+<!-- prettier-ignore-start -->
2222+2323+[mdbook-init-logger]: https://github.com/rust-lang/mdBook/blob/v0.5.2/src/main.rs#L94-L97
2424+[mdbook-init-logger-v0.4]: https://github.com/rust-lang/mdBook/blob/v0.4.52/src/main.rs#L111-L112
2525+2626+<!-- prettier-ignore-end -->
+6
docs/src/snippets/logging/output-style.md
···11+By default, the preprocessor reports progress using a spinner, and diagnostic
22+information (such as broken links) are displayed in a graphical manner, similar to how
33+rustc emits errors.
44+55+If `MDBOOK_LOG` is set, or if [`CI=true`](continuous-integration.md), then all messages
66+are emitted as logs instead.