NAME Mojo::Log::Clearable - Mojo::Log with clearable log handle SYNOPSIS use Mojo::Log::Clearable; my $log = Mojo::Log::Clearable->new(path => $path1); $log->info($message); # Logged to $path1 $log->path($path2); $log->debug($message); # Logged to $path2 $log->path(undef); $log->warn($message); # Logged to STDERR # Reopen filehandle after logrotate (if logrotate sends SIGUSR1) $SIG{USR1} = sub { $log->clear_handle }; DESCRIPTION Mojo::Log is a simple logger class. It holds a filehandle once it writes to a log, and changing "path" does not open a new filehandle for logging. Mojo::Log::Clearable subclasses Mojo::Log to provide a "clear_handle" method and to automatically call it when setting "path" so the logging handle is reopened at the new path. The "clear_handle" method can also be used to reopen the logging handle after logrotate. EVENTS Mojo::Log::Clearable inherits all events from Mojo::Log. ATTRIBUTES Mojo::Log::Clearable inherits all attributes from Mojo::Log and implements the following new ones. path my $path = $log->path; $log = $log->path('/var/log/mojo.log'); Log file path used by "handle" in Mojo::Log. Reopens the handle when set. METHODS Mojo::Log::Clearable inherits all methods from Mojo::Log and implements the following new ones. clear_handle $log->clear_handle; Clears "handle" in Mojo::Log attribute, it will be reopened from the "path" attribute when next accessed. AUTHOR Dan Book, dbook@cpan.org COPYRIGHT AND LICENSE Copyright 2015, Dan Book. This library is free software; you may redistribute it and/or modify it undef the terms of the Artistic License version 2.0. SEE ALSO Mojo::Log