packages/docs/plugins/logger.md
The Logger API gives plugins structured, leveled logging. All log output is routed through Nuclear's logging system, which writes to the app's log file and the developer console.
These logs can also be viewed in the built-in log viewer (Preferences → Logs).
Access the logger via api.Logger.* in any lifecycle hook:
import type { NuclearPlugin, NuclearPluginAPI } from '@nuclearplayer/plugin-sdk';
const plugin: NuclearPlugin = {
onEnable(api: NuclearPluginAPI) {
api.Logger.info('Plugin enabled');
api.Logger.debug('Loaded 42 cached entries');
},
onDisable(api: NuclearPluginAPI) {
api.Logger.info('Plugin disabled');
},
};
export default plugin;
{% hint style="info" %}
All Logger methods are synchronous and return void. They never throw.
{% endhint %}
Levels follow standard severity ordering, from most verbose to most severe: trace → debug → info → warn → error.
You can also call api.Logger.log(level, message) with any LogLevel value directly. This is useful when the level is determined at runtime.
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
api.Logger.trace(message: string): void
api.Logger.debug(message: string): void
api.Logger.info(message: string): void
api.Logger.warn(message: string): void
api.Logger.error(message: string): void
api.Logger.log(level: LogLevel, message: string): void