Hi there, Timber

Verbb Team Verbb Team Feb 2023 2 min read

There's plenty of times we've needed to check out the raw log files for a Craft site. Whether that be to send to a plugin developer (we often ask you for them!) or diagnosing super-urgent issues. They're a treasure trove of vital information — which until now are only really accessible to people with access to your server.

Introducing Timber#

Timber gives you access to your log files directly within the control panel. You can even give your clients access to it if they're tech-savvy. It's a simple idea, but we've added the bells and whistles to make the experience a good one.

Check out your logs from the control panel

First, pick the log file to view, which then populates a table with each entry in the log file. You can filter based on the "level" (error, warning, info, etc), and even by the "category" (useful for identifying plugins vs. Craft logs). There's full-text searching and of course, being able to sort.

Performance#

We know from experience log files can get out of hand — size-wise — pretty fast. Fortunately, Craft 4 has introduced splitting log files and rotations, but there's still cases large log files can exist. It was vital from the start that Timber handle large log files well — and it does!

We employ a few things to keep performance in check:

  • Reading log files is done per-line, rather than loading the entire file into memory.
  • Log files are parsed into structured data and cached for next time.
  • Pagination of 100 (configurable) so not all log entries are rendered.

With these techniques, a 1GB log file takes about 15 seconds to load on a development environment and 5 seconds to load on a production environment.

Real-time Logging#

A neat little feature we wanted to introduce was real-time logging. That means that you can sit on the Timber log screen and wait for new log entries to come in, without having to refresh the page. You'll get a small alert notifying you that there's new log entries, and you can load them. All thanks to the power of WebSockets, and the tail command.

Timber will let you know when there's new log entries

Wrap up#

While it's not the most ground-breaking of plugins, it's a simple and common use-case we think everyone could benefit from. Hopefully, Timber will come in handy next time you're in a rush for log file content, or if you're unable to gain server access easily when you're in need of support.

Timber (opens new window) is available today for Craft 4 for $19.