> module
std::log
structured logging
std::log emits log events through the tracing crate. Configure a subscriber with subscriber(), install it with init(), then log with trace, debug, info, warn and error. Until a subscriber is installed, events go nowhere unless the host program set one up.
> functions
Emits an event at that level, with the message formatted as by fmt::format. With no args the message is used as is.
Emits an event at that level, with the message formatted as by fmt::format. With no args the message is used as is.
Emits an event at that level, with the message formatted as by fmt::format. With no args the message is used as is.
subscriber() -> SubscriberBuilderA new builder with the defaults: level info, the full format on stderr, targets and ANSI colours on, file names and line numbers off.
Emits an event at that level, with the message formatted as by fmt::format. With no args the message is used as is.
> types
An opaque value; see the functions that return it.
Each method except init returns a new builder; the original is unchanged.
The builder exposed to xur scripts as a native object.
subscriber_builder.compact() -> SubscriberBuilderWrites events as JSON lines, in the multi-line pretty format, or in the compact single-line format.
subscriber_builder.init()Installs the subscriber for the whole process. It is a runtime error if a subscriber is already installed or the log file can't be opened.
subscriber_builder.json() -> SubscriberBuilderWrites events as JSON lines, in the multi-line pretty format, or in the compact single-line format.
subscriber_builder.pretty() -> SubscriberBuilderWrites events as JSON lines, in the multi-line pretty format, or in the compact single-line format.
subscriber_builder.to_file(path: str) -> SubscriberBuilderAppends output to the file at path, creating it if needed, instead of writing to stderr.
subscriber_builder.to_stderr() -> SubscriberBuilderWrites output to stderr (the default).
subscriber_builder.truncate() -> SubscriberBuilderWith to_file, empties the file when the subscriber is installed.
subscriber_builder.with_ansi(v: bool) -> SubscriberBuilderTurns ANSI colours on or off. Output to a file never has colours.
subscriber_builder.with_file(v: bool) -> SubscriberBuilderShows or hides the source file and line number.
subscriber_builder.with_filter(filter: str) -> SubscriberBuilderFilters events with a tracing EnvFilter directive such as "debug,xur_std::log=info", instead of the max level. Directives also apply to Rust code logging in the same process, such as a stub's host. If the RUST_LOG environment variable is set, it is used instead.
subscriber_builder.with_line_number(v: bool) -> SubscriberBuilderShows or hides the source file and line number.
subscriber_builder.with_max_level(level: Level | str) -> SubscriberBuilderLogs events at level and above. level is a Level or one of the strings "trace", "debug", "info", "warn" and "error"; anything else is a runtime error.
subscriber_builder.with_target(v: bool) -> SubscriberBuilderShows or hides each event's target. Events from scripts all have the target xur_std::log.
> level
log::Level is an enum of severities, lowest first: Trace, Debug, Info, Warn and Error.
> examples
use std::log;
use std::io;
fn main() {
log::subscriber()
.with_max_level(log::Level::Debug)
.with_ansi(true)
.init();
log::info("application started");
log::debug("value: {}", 42);
log::warn("something to watch");
}