The Status and Logging API provides methods for communicating with users through status messages and logging plugin activity for debugging and monitoring.
Text to display (keep short - status bar has limited width)
The message will be shown until the next status update or user action. Use for feedback on completed operations (e.g., “File saved”, “2 matches found”).
Example:
// Simple status messageeditor.setStatus("File saved successfully");// Status with dynamic contentconst count = results.length;editor.setStatus(`Found ${count} matches`);// Status after operationawait editor.spawnProcess("git", ["pull"]);editor.setStatus("Git pull completed");
Fresh provides four log levels for plugin messages. Messages appear in the log file when running with appropriate RUST_LOG environment variable settings.
debug(): Development info, variable values, function entry/exit
info(): Important milestones, configuration loaded, plugin initialized
warn(): Recoverable issues, missing config, deprecated features
error(): Critical failures, exceptions, data corruption
Include context in messages
Make log messages self-explanatory by including relevant context:
// Badeditor.debug("Processing");// Goodeditor.debug(`Processing ${files.length} files from ${directory}`);
Use setStatus for user feedback
Status messages are for users, log messages are for developers:
// User sees thiseditor.setStatus("Search completed");// Developer sees this in logseditor.info(`Search found ${results.length} matches in ${elapsed}ms`);
Keep status messages concise
The status bar has limited width. Keep messages short and clear:
// Goodeditor.setStatus("Saved");editor.setStatus("3 errors, 2 warnings");// Too longeditor.setStatus("File has been successfully saved to disk at /very/long/path/...");