NAME

Mojolicious::Plugin::MoreLog - Add printf and dump methods to Mojo::Log

SYNOPSIS

plugin 'MoreLog';

# Later in your app
$app->log->printf("User %s logged in", $user);
$app->log->dump($data);

DESCRIPTION

Mojolicious::Plugin::MoreLog is a plugin for Mojolicious that monkey-patches Mojo::Log to add two convenience methods: dump and printf.

These methods allow quick structured logging and formatted message logging respectively.

METHODS

register

$plugin->register($app, \%conf);

Registers the plugin and injects the following methods into Mojo::Log:

  • dump(@args)

    Logs a data dump of the arguments using "dumper" in Mojo::Util at info level.

    $app->log->dump($user);
    $app->log->dump($user, $session, \%env);
  • printf($format, @args)

    Logs a message using sprintf with the provided format string and arguments, also at info level.

    $app->log->printf("Logged in user %s with ID %d", $name, $id);

SEE ALSO

Mojolicious, Mojo::Log, "monkey_patch" in Mojo::Util, "dumper" in Mojo::Util

AUTHORS

Simone Cesano <scesano@cpan.org>

This software is copyright (c) 2021 by Simone Cesano.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.