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

# Helpers

The package exposes one resolver helper and five convenience helpers.

## `logger()`

```php
function logger(?string $adapter = null): Logger
```

Use this when you want the full logger instance.

```php
$logger = logger();
$logger->error('Payment capture failed');
```

Pass an adapter name when you need a specific backend in normal runtime:

```php
$logger = logger(LoggerType::DAILY);
$logger->warning('Slow downstream response');
```

Remember that debug mode overrides adapter selection to `message`.

## Level helpers

The package also provides these global helpers:

* `error(string $message, array $context = [])`
* `warning(string $message, array $context = [])`
* `notice(string $message, array $context = [])`
* `info(string $message, array $context = [])`
* `debug(string $message, array $context = [])`

Each helper resolves the default logger through `LoggerFactory::get()` and immediately calls the matching method.

Example:

```php
error('Order export failed', ['trace' => $exception->getTraceAsString()]);
```

## Helper caveats

A few limits are easy to miss:

* the convenience helpers do not let you choose an adapter
* there are no global helpers for `critical`, `alert`, or `emergency`
* the convenience helpers accept string messages, while `logger()` also lets you send array payloads through the PSR-3 methods
* every helper call goes back through the shared factory
* in debug mode, helper output goes to the debugger message store instead of files

Use `logger()` when you need the full PSR-3 surface, adapter selection, or structured array messages.


---

# 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://quantumphp.gitbook.io/docs/packages/logger/helpers.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.
