Event Logging
lc_plugin::log provides a typed event log for import and export diagnostics. Messages written through EventLog appear in LinkCAD’s log UI and can mark a conversion as fatal.
Python exposes the same logging model through linkcad.v1.env.EventLog.
Key Public Items
| Item | Purpose |
|---|---|
EventLog | Host-owned event log wrapper. |
Severity | Log severity level. |
Severity
pub enum Severity { Info, Warning, Error,}Use Info for status messages, Warning for recoverable issues, and Error for failures that the user should act on.
Host Construction
pub unsafe fn from_raw(ptr: *mut LcEventLog) -> Self;This method is public for ABI glue. Plugin code normally obtains an event log from DrawingBuilder::log(), WriterController::log(), or the log parameter in Reader::post_process().
Methods
| Method | Description |
|---|---|
log(severity: Severity, message: &str) | Write a message. |
log2(severity: Severity, title: &str, description: &str) | Write a titled message with a description. |
set_fatal() | Mark the log state as fatal. |
is_fatal() -> bool | Return whether the log state is fatal. |
info(message: &str) | Convenience wrapper for Severity::Info. |
warning(message: &str) | Convenience wrapper for Severity::Warning. |
error(message: &str) | Convenience wrapper for Severity::Error. |
String inputs are truncated at the first interior NUL byte instead of panicking.
Import Example
fn parse_file( &mut self, path: &str, builder: &mut DrawingBuilder, _file_size: i64, _current_file: i32, _file_count: i32,) -> bool { let mut log = builder.log(); log.info(&format!("Reading {path}"));
if path.is_empty() { log.error("No input file was provided"); log.set_fatal(); return false; }
true}Export Example
fn write_file(&mut self, path: &str, ctrl: &mut WriterController) -> bool { let mut log = ctrl.log(); log.log2( Severity::Info, "Export started", &format!("Writing {path}"), ); true}Return false from the host callback when an error should stop import or export. Use set_fatal() when the failure should be treated as a fatal conversion state.