Hi,
not entirely sure I understand your question but here's what I am doing:
in lib/AppLog.pm:
package AppLog;
use Mojo::Base 'Mojo::Log';
use Time::HiRes qw( gettimeofday );
sub format {
my ($self, $level, @lines) = @_;
my ($s,$f) = gettimeofday;
return '[' . localtime(time) . '] [+' . $f . " us] [$level] " .
join("\n", @lines) . "\n";
}
1;
In my application:
use AppLog;
...
sub startup {
my $self = shift;
my $config = $self->plugin('Config' => {file => 'settings.conf'});
$self->log(AppLog->new(path => $self->log->path, level =>
$self->log->level || 'debug')) if $config->{log}->{hires};
...
}
You'll notice that I replace the existing log instance with my own.
If you just want to use the existing one then with a controller subroutine
you can write:
$self->app->log->debug(...); # $self being the controller instance
Allan
On Wednesday, 10 September 2014 12:49:43 UTC-5, Ed Rantanen wrote:
>
> I am sure this has been asked ..
> And I have done some googling on this but can find a solution.
>
>
> I am new to mojolicious, and trying to learn the structure I thought
> something interesting(easy) might be to start by modifying the logs.
>
> Under my_app/log/ there is a development.log.
>
> What I am having a hard time with is how to integrate Mojo::Log
> http://mojolicio.us/perldoc/Mojo/Log
>
> I have tried to use it in script/my_app and a mojo.log is created but only
> initially used.
> The same with in lib/My_App.pm.
>
> So is the log modification meant to be built into the controller?
>
> If someone has a howto on this would be appreciated.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.