Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/docs/frontend/bareui.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,4 @@ To include a sub-template in a template, you can use the `$template::render()` m
</body>
```

All BareUI templates have access to the `$template` variable, which is an instance of the BareUI engine. Calling the `render()` method on this variable will include the specified sub-template in the current template.
All BareUI templates have access to the `$template` variable, which holds the BareUI class name, so `$template::render()` is a static call. Calling `render()` this way will include the specified sub-template in the current template.
29 changes: 29 additions & 0 deletions src/docs/routing/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ app()->config([
]);
```

You can change how each entry is formatted with the `log.style` configuration option. It accepts `leaf` (the default) or `linux`:

```php
app()->config([
'log.enabled' => true,
'log.style' => 'linux'
]);
```

With `leaf`, the timestamp sits on its own line above the message. With `linux`, each entry is a single line, like a system log:

```text:no-line-numbers
[2026-11-13 09:31:40] ERROR - Something went wrong
```

By default new entries are appended to the end of the file. If you prefer the old newest-first layout, set `log.mode` to `prepend` (this rewrites the whole file on every entry, so avoid it on busy production apps).

:::

::: details Usage with Leaf MVC
Expand All @@ -169,6 +186,18 @@ That's it! Leaf will no longer log errors or exceptions for your app.

:::

### Writing your own log entries

Once logging is enabled, `app()->logger()` gives you the logger instance, so you can log your own messages and not only errors:

```php
app()->logger()->info('User signed up', ['id' => 12]);
app()->logger()->warning('Disk space is low');
app()->logger()->error('Payment failed');
```

Each level method (`debug`, `info`, `notice`, `warning`, `error`, `critical`, `alert`, `emergency`) writes to the log file you configured. If logging isn't enabled or the logger module isn't installed, `app()->logger()` triggers an error telling you to set `log.enabled` and install the module.

## Rescue Helper

Leaf provides a shorter way to handle exceptions using the `rescue()` function. It runs your callback, catches anything thrown inside it, reports the exception to Crash, and returns a default value. This way, you can use try-catch with a more inline syntax.
Expand Down