Web::ChromeLogger - ChromeLogger for Perl
use Web::ChromeLogger; get '/', sub { my $logger = Web::ChromeLogger->new(); $logger->info('hey!'); $logger->infof('Hello, %s!', 'John'); my $html = render_html(); return [ 200, ['X-ChromeLogger-Data' => $logger->finalize()], $html, ]; };
Web::ChromeLogger is a ChromeLogger library for Perl5.
Chrome Logger is a Google Chrome extension for debugging server side applications in the Chrome console.
This module generates the string for ChromeLogger. You can send the string in 'X-ChromeLogger-Data' header in HTTP response.
For more details, please see ChromeLogger's Technical Specification
If you are using nginx as reverse proxy, you may need to set following parameters in your configuration file:
proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k;
Chrome has a limit of 250kb across all headers for a single request so that is the maximum amount of encoded data you can send.
250kb
my $logger = Web::ChromeLogger->new(%args)
Create new instance with following parameters:
JSON::XS->new()->ascii(1)->convert_blessed
JSON encoder object. You can use JSON::XS or JSON::PP for this.
I guess you don't need to set this parameter.
$logger->group($title: Str)
$logger->groupf($format: Str, @list)
Push group.
group
$logger->group_end($title: Str)
$logger->group_endf($format: Str, @list)
Push groupEnd.
groupEnd
$logger->group_collapsed($title: Str)
$logger->group_collapsedf($format: Str, @list)
Push groupCollapsed.
groupCollapsed
$logger->info($title: Str)
$logger->infof($format: Str, @list)
Push info.
info
$logger->warn($title: Str)
$logger->warnf($format: Str, @list)
Push warn.
warn
$logger->error($title: Str)
$logger->errorf($format: Str, @list)
Push error.
error
$logger->wrap_by_group($title: Str)
$logger->wrap_by_groupf($format: Str, @list)
Wrap current logging data by $title group.
$title
$logger->finalize()
Generate header string.
Copyright (C) Tokuhiro Matsuno.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Tokuhiro Matsuno <tokuhirom@gmail.com>
moznion
ChromeLogger
To install Web::ChromeLogger, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Web::ChromeLogger
CPAN shell
perl -MCPAN -e shell install Web::ChromeLogger
For more information on module installation, please visit the detailed CPAN module installation guide.