Skip to content

Commit

Permalink
improved logging of low level exceptions in Mojolicious
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 14, 2012
1 parent 49654b2 commit e5d214d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,6 +1,7 @@
This file documents the revision history for Perl extension Mojolicious.

2.62 2012-03-14 00:00:00
- Improved logging of low level exceptions in Mojolicious.
- Improved documentation.

2.61 2012-03-14 00:00:00
Expand Down
7 changes: 6 additions & 1 deletion lib/Mojo.pm
Expand Up @@ -3,8 +3,10 @@ use Mojo::Base -base;

use Carp 'croak';
use Mojo::Home;
use Mojo::IOLoop;
use Mojo::Log;
use Mojo::Transaction::HTTP;
use Mojo::UserAgent;
use Scalar::Util 'weaken';

has home => sub { Mojo::Home->new };
Expand All @@ -13,7 +15,6 @@ has ua => sub {
my $self = shift;

# Fresh user agent
require Mojo::UserAgent;
my $ua = Mojo::UserAgent->new->app($self);
weaken $self;
$ua->on(error => sub { $self->log->error(pop) });
Expand All @@ -33,6 +34,10 @@ sub new {
$self->log->path($self->home->rel_file('log/mojo.log'))
if -w $self->home->rel_file('log');

# Low level exception handling
Mojo::IOLoop->singleton->iowatcher->on(
error => sub { $self->log->error(pop) });

return $self;
}

Expand Down
3 changes: 0 additions & 3 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -14,9 +14,6 @@ use POSIX qw/setsid WNOHANG/;
use Scalar::Util 'weaken';
use Time::HiRes 'ualarm';

# Preload
use Mojo::UserAgent;

sub DESTROY {
my $self = shift;

Expand Down

0 comments on commit e5d214d

Please sign in to comment.