Skip to content

Commit

Permalink
removed close method from Mojo::Log again
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 1, 2012
1 parent de05199 commit 12aea65
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 16 deletions.
1 change: 0 additions & 1 deletion Changes
Expand Up @@ -2,7 +2,6 @@ This file documents the revision history for Perl extension Mojolicious.

2.71 2012-04-01
- Added simple log rotation support with USR1 signal to Hypnotoad.
- Added close method to Mojo::Log.
- Improved Hypnotoad error handling.
- Improved documentation.
- Improved tests.
Expand Down
8 changes: 0 additions & 8 deletions lib/Mojo/Log.pm
Expand Up @@ -44,8 +44,6 @@ sub new {
return $self;
}

sub close { delete shift->{handle} }

# "Yes, I got the most! I win X-Mas!"
sub debug { shift->log(debug => @_) }
sub error { shift->log(error => @_) }
Expand Down Expand Up @@ -187,12 +185,6 @@ the following new ones.
Construct a new L<Mojo::Log> object and subscribe to C<message> event with
default logger.
=head2 C<close>
$log->close;
Close C<handle>, useful for log rotation.
=head2 C<debug>
$log = $log->debug('You screwed up, but that is ok');
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -106,7 +106,7 @@ sub run {
};
$SIG{QUIT} = sub { $self->{finished} = $self->{graceful} = 1 };
$SIG{USR1} = sub {
$log->info('Reopening log file.')->close;
delete $log->info('Reopening log file.')->{handle};
kill 'USR1', $_ for keys %{$self->{workers}};
};
$SIG{USR2} = sub { $self->{upgrade} ||= time };
Expand Down Expand Up @@ -355,7 +355,7 @@ sub _spawn {
# Clean worker environment
$SIG{INT} = $SIG{TERM} = $SIG{CHLD} = $SIG{USR2} = $SIG{TTIN} = $SIG{TTOU} =
'DEFAULT';
$SIG{USR1} = sub { $self->{daemon}->app->log->close };
$SIG{USR1} = sub { delete $self->{daemon}->app->log->{handle} };
$SIG{QUIT} = sub { $loop->max_connections(0) };
delete $self->{reader};
delete $self->{poll};
Expand Down
6 changes: 1 addition & 5 deletions t/mojo/log.t
@@ -1,6 +1,6 @@
use Mojo::Base -strict;

use Test::More tests => 48;
use Test::More tests => 45;

# "Don't let Krusty's death get you down, boy.
# People die all the time, just like that.
Expand All @@ -14,10 +14,6 @@ use Mojo::Log;
my $dir = File::Temp::tempdir(CLEANUP => 1);
my $path = catdir $dir, 'test.log';
my $log = Mojo::Log->new(level => 'debug', path => $path);
ok $log->handle, 'file has been opened';
ok !$log->handle(undef)->handle, 'handle has been replaced';
$log->close;
ok $log->handle, 'file has been reopened';
$log->debug('Just works.');
$log = Mojo::Log->new;
like(
Expand Down

0 comments on commit 12aea65

Please sign in to comment.