augensalat / mojolicious-plugin-accesslog Goto Github PK
View Code? Open in Web Editor NEWEasily generate access logs for Mojolicious applications
Easily generate access logs for Mojolicious applications
Documentation says I should write:
# Mojolicious
$self->plugin(AccessLog => {log => '/var/log/mojo/access.log'});
But when I include the uname_helper setting as such:
sub startup {
my $app = shift;
$app->plugin(AccessLog => {
log => '/dev/null',
uname_helper => 'set_username',
});
$app->hook(around_action => sub {
my ($next, $c, $action) = @_;
$c->set_username('alex');
});
}
...then I get this error:
Can't locate object method "set_username" via package "Web::Ctrl1"
...where Web::Ctrl1 is the name of my controller that contains the route handlers. Everything else works on my website, except this, which produces this error.
How do I fix it? The AccessLog's documentation is not clear on this.
I'm doing this now: (which of course is not very nice)
{
require Mojolicious::Plugin::AccessLog;
no warnings 'redefine';
my $hack = \&Mojolicious::Plugin::AccessLog::_log;
*Mojolicious::Plugin::AccessLog::_log = sub {
my($c, @args) = @_;
local $main::LOG_KEY = $c->session('reference') || $c->session('username');
MyLogger->log(info => $hack->($c, @args));
};
}
$app->plugin('Mojolicious::Plugin::AccessLog' => log => sub {});
Is there a way you could add a "log" callback which gets $c passed on as well as the log message? Or would you consider taking a pull request for this feature?
Do you have an advice what's the best way to prevent forking workers logging twice?
Grateful for any insight you can provide.
==> api.err.log <==
[Sat Nov 21 22:41:50 2015] [warn] Mojolicious::Plugin::AccessLog::VERSION = 0.010
I think this is useless, and shouldn't be there since I didn't do anything wrong to get warned about.
CPAN is still on version 0.004. When do you publish 0.005?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.