Skip to main content

set_logger

Function set_logger 

Source
pub fn set_logger(f: Option<Box<dyn Logger>>) -> Result<()>
Expand description

Set the log callback.

When set, internal library log messages are delivered to this callback. When cleared (set to None), log messages are silently discarded.

Which log levels are emitted depends on the build mode of the library and is not configurable at runtime. Debug builds emit all levels (debug and above). Release builds emit info and above; debug-level messages are compiled out entirely and will never reach the callback.

§Examples

Use LogStderr as a simple way to write formatted logs to stderr:

use libghostty_vt::{set_logger, log::LogStderr};
set_logger(Some(Box::new(LogStderr)))?;

When the log feature is enabled, you can also redirect log messages to any log-compatible logger, including the one currently used globally:

// Any logger will do, though usually you want to use the global logger
libghostty_vt::set_logger(Some(Box::new(log::logger())))?;