Nic Sandfield

NAME

Mojolicious::Plugin::Log::Timestamp - Provide customised log timestamps

SYNOPSIS

  # Mojolicious
  $self->plugin('Log::Timestamp');

  # Mojolicious::Lite
  plugin 'Log::Timestamp';

DESCRIPTION

Mojolicious::Plugin::Log::Timestamp is a Mojolicious plugin for customising log timestamps in your web application.

USAGE

Simply add the plugin as shown above and you will get fairly compact ISO-style timestamps as '%Y%m%d %H:%M:%S'. To set a custom timestamp pattern, just pass it to the plugin.

  # Mojolicious
  $self->plugin('Log::Timestamp' => {pattern => '%F %X '});

  # Mojolicious::Lite
  plugin 'Log::Timestamp' => {pattern => '%F %X '};

See Mojar::Log for more examples. If you want ISO 8601, use '%FT%X ', optionally omitting the 'T'. Trailing whitespace is significant. If you want ultra compact, try '%y%m%d%H%M%S'.

In addition to 'pattern', you can include any of the usual Mojo::Log parameters such as 'path' and 'level'.

METHODS

Mojolicious::Plugin::Log::Timestamp inherits all methods from Mojolicious::Plugin.

register

  $plugin->register(Mojolicious->new);

Register plugin in Mojolicious application.

RATIONALE

Usually you want your log timestamps to just do their job in the fewest characters practical. And everyone is entitled to their own view as to what a log timestamp should look like. Personally I usually choose '%y%m%d %X'. But none of this deservers absorbing your attention, so you just use the plugin and get on with the real work.

COPYRIGHT AND LICENSE

Copyright (C) 2014, Nic Sandfield.

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

SEE ALSO

Mojar::Log, Mojo::Log, Mojolicious::Plugin::Log::Access, Mojolicious::Guides.