Logginz ur console with Mojolicious

A new Mojolicious plugin has been released, Mojolicious::Plugin::ConsoleLogger.

By default, Mojolicious will send debug messages to a log/[mode].log file; if the log directory does not exist, messages will default to the terminal console.

You can use any of the four logging groups for customized messages:

With Mojolicious::Plugin::ConsoleLogger, you can log these same messages directly to your browser console.

Declare the plugin:

And view all your log messages directly from your browser:

console logger devtools screenshot.png

That's all well and good, but let's take it a step further. You can even see error messages when the template is missing:

template not found browser console error.png

Or when there's a template error:

syntax error template mojo console logger.png

Even when there's a Perl compilation error:

perl error mojo console logger.png

As always, Mojolicious installs in about a minute:
sudo -s 'curl -L cpanmin.us | perl - Mojolicious::Plugin::ConsoleLogger'

Disclaimer:
Implementation stolen from Plack::Middleware::ConsoleLogger

Leave a comment

About tempire

user-pic I do not like the status quo. There is always a better way; the question is whether you care enough to find it.