> For the complete documentation index, see [llms.txt](https://docs.nuclearplayer.com/nuclear/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nuclearplayer.com/nuclear/plugins/logger.md).

# Logger

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).

***

## Usage

Access the logger via `api.Logger.*` in any lifecycle hook:

```typescript
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 %}

***

## Log levels

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.

***

## Reference

```typescript
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
```

***

## Notes

* All methods are synchronous. They accept a string and return nothing.
* If no logger host is provided (e.g. during testing), every method no-ops.
* Log output goes to Nuclear's logging system, which writes to the app's log file on disk devtools console, terminal console, and the built-in log viewer (Preferences → Logs).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nuclearplayer.com/nuclear/plugins/logger.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
