Need to capture Log of each thread --Parallel::ForkManager;

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Hi All,
In one of my application,i am cloning  a process to 4 different
threads,using Parallel::ForkManager module.
Can anyone tell me how can i track each thread ,and is it possible to
create separate log files for each thread.

My Program is something like this....

my $child_proc_mgr=new Parallel::ForkManager($maxprocesses);
for(my $i = $from; $i <=$to; $i++)
{       my $sourcefname=$tmpfname;
        my $targetfname=$targetdir;
        $sourcefname .= "/".sprintf('%03s',$i);
        $targetfname .= "/".sprintf('%03s',$i).".gz";
        next if (-e "$targetfname");
        next if (-e "$sourcefname.sorting");
        next if (-e "$sourcefname.sorted");
        $child_proc_mgr->start and next;
        my ($src,$sorting,$sorted);
        die "\nFile $sourcefname does not exists"  if (! -e
        open ($src,"< $sourcefname") || die "\nCannot open
$sourcefname for reading $!";
        open ($sorting,"> $sourcefname.sorting") ||
                die "\nCannot open temp file $sourcefname.sorting for
writing $!";
        close $src;
        close $sorting;
        print "\nSorting file $sourcefname";
        my $sortstatus= $? >> 8;
        if ($sortstatus != 0)
        {       unlink $targetfname;
                die "\n $sourcefname.sorting -- Sort was failed $!";
                print "Sorting successful for file
$sourcefname.sorting to $sourcefname.sorted";

Right now proper logging is not happening,many of the print statements
i have given are not getting captured for each thred.
Any pointers to this will be highly appreciated.


Site Timeline