Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhthorsen/mojo-log-role-format
https://github.com/jhthorsen/mojo-log-role-format
Last synced: 27 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jhthorsen/mojo-log-role-format
- Owner: jhthorsen
- Created: 2022-03-16T11:00:52.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-22T16:09:45.000Z (about 2 years ago)
- Last Synced: 2024-10-16T11:58:42.373Z (3 months ago)
- Language: Perl
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
Awesome Lists containing this project
README
# NAME
Mojo::Log::Role::Format - Add sprintf logging to Mojo::Log
# SYNOPSIS
use Mojo::Log;
my $log = Mojo::Log->new->with_roles('+Format')->level('debug');# [info] cool beans
$log->logf(info => 'cool %s', 'beans');# [warn] serializing {"data":"structures"}
$log->logf(warn => 'serializing %s', {data => 'structures'});# DESCRIPTION
[Mojo::Log::Role::Format](https://metacpan.org/pod/Mojo%3A%3ALog%3A%3ARole%3A%3AFormat) is a [Mojo::Log](https://metacpan.org/pod/Mojo%3A%3ALog) role which allow you to log with
a format like `sprintf()`, avoid "Use of uninitialized" warnings and will
also serialize data-structures and objects.# ATTRIBUTES
## logf\_serialize
$cb = $log->logf_serialize;
$log = $log->logf_serialize(sub (@args) { ... });This attribute must hold a callback that will be used to serialize the arguments
passed to ["logf"](#logf).The default callback uses [Data::Dumper](https://metacpan.org/pod/Data%3A%3ADumper) with some modifications, but these
settings are currently EXPERIMENTAL and subject to change:$Data::Dumper::Indent = 0;
$Data::Dumper::Maxdepth = $Data::Dumper::Maxdepth || 2;
$Data::Dumper::Pair = ':';
$Data::Dumper::Quotekeys = 1;
$Data::Dumper::Sortkeys = 1;
$Data::Dumper::Terse = 1;
$Data::Dumper::Useqq = 1;# METHODS
## logf
$log = $log->logf($level => $format, @args);
$log = $log->logf($level => $message);See ["SYNOPSIS"](#synopsis).
# AUTHOR
Jan Henning Thorsen
# COPYRIGHT AND LICENSE
This library is free software. You can redistribute it and/or modify it under
the same terms as Perl itself.# SEE ALSO
[Mojo::Log](https://metacpan.org/pod/Mojo%3A%3ALog)