use IO::Async::Loop; use IO::Async::Function; use strict; use warnings; use Log::Log4perl; unless ( Log::Log4perl->initialized() ) { Log::Log4perl::init("~/blah.cfg"); } my $logger = Log::Log4perl->get_logger('main.log1'); $logger->info( "$$: Starting" ); my $loop = IO::Async::Loop->new; my $function = IO::Async::Function->new( code => sub { my ( $in_num ) = @_; my $logThing = LogThing->new(); $logThing->do_it( $in_num ); return( $in_num + 1 ); }, ); $loop->add( $function ); my @futures; foreach my $num ( 2..3 ) { push @futures, $function->call( args => [ $num ] ); } $loop->await_all( @futures ); $function->stop; $logger->info( "$$: Exiting" ); 0; package LogThing; use Moose; use strict; use warnings; use Log::Log4perl; use Try::Tiny; sub do_it { my ( $self, $in_num ) = @_; my $logger = Log::Log4perl->get_logger('main.trans'); print "Sleeping $in_num\n"; sleep( $in_num ); try { $logger->info("$$: Done $in_num"); } catch { warn "Some weird log4perl object conflict $_"; }; } 0;