Expand description
The logging library for Rem-Verse.
Some Key Features:
- Multiple Logging Formats, that are built for many individuals.
- Colored for pretty ascii color & erasing interfaces.
- Plaintext for a simple line based format ideal for braille displays, and log files.
- JSON for structured logging, with quick parsing/slicing/dicing support.
- Task Status, and Logging.
- Queue up many background tasks, and have log lines prefixed with task names, and status updates.
- Shell Interface Building with tab-complete support.
- Full customization at runtime of data to include by users.
§Getting started
To get started, you should simply initialize the super console at the start of the program, and keep a guard dropping it when you want to ensure all logs are flushed (e.g. at program exit.). This does assume your program is running in a tokio runtime.
use rm_lisa::initialize_logging;
async fn my_main() {
let console = initialize_logging("my-application-name").expect("Failed to initialize logging!");
// ... do my stuff ...
console.flush().await;
}Once you’ve initialized the super console, all you need to do is use tracing like normal:
use tracing::info;
info!("my cool log line!");You can also specify a series of fields to customize your log message. Like:
lisa.force_combine_fields: force combine the metadata, and message to render (e.g. render without the gutter).lisa.hide_fields_for_humans: hide any fields that probably aren’t useful for humans. (e.g.id).lisa.subsystem: the ‘name’ of the the system that logged this line. Renders in the first part of the line instead of application name.lisa.stdout: for this log line going to STDOUT instead of STDERR.lisa.decorate: render the application name/log level on text rendering.
These messages can be set on individual log messages themselves or set for everything in a scope:
use tracing::{Instrument, error_span, info};
async fn my_cool_function() {
async {
info!("Hello with details from span!");
}.instrument(
// we want our span attached to every message, making it error ensures that happens.
error_span!("my_span", lisa.subsystem="my_cool_task", lisa.stdout=true)
);
}It is also recommended to include an id set to a unique string per log
line. As when a user requests JSON output, without an ID it can be hard to
know what schema the log will be following (What fields will be presenet,
etc.). Having an id field can be used for that, and will be hidden on
color/text renderers automatically as they are not useful there.
Modules§
- display
SuperConsole; The Structure that renders everything.- errors
- List of all errors for this crate.
- input
- Handle receiving input from somewhere, and use it to produce strings somewhere else.
- tasks
- A very small module meant to use to track ‘in-progress’ tasks.
- termios
- A wrapper around termios APIs.
Functions§
- app_
name_ to_ prefix - Create an environment variable prefix given an application name.
- initialize_
logging - Initialize the Lisa logger, this will error if we run into any errors actually setting up everything that needs to be set-up.
- initialize_
with_ console - Initialize the Lisa logger with a pre-configured super console.