Improved solution

This commit is contained in:
Jose Gonzalez 2019-10-07 10:31:59 +02:00
parent 7bdd2a02e5
commit 662e86c1c2
1 changed files with 3 additions and 1 deletions

View File

@ -652,7 +652,9 @@ sub logger ($$;$) {
# Obtain the script that invoke this log # Obtain the script that invoke this log
my $parent_caller = ""; my $parent_caller = "";
if (($parent_caller = ( caller(2) )[1]) ne "") { if (($parent_caller = ( caller(2) )[1]) ne "") {
$parent_caller = " ** " . (split '/', $parent_caller)[-1] . " **:"; $parent_caller = (split '/', $parent_caller)[-1];
$parent_caller =~ s/\.[^.]+$//;
$parent_caller = " ** " . $parent_caller . " **:";
} }
open (FILE, ">> $file") or die "[FATAL] Could not open logfile '$file'"; open (FILE, ">> $file") or die "[FATAL] Could not open logfile '$file'";
# Get an exclusive lock on the file (LOCK_EX) # Get an exclusive lock on the file (LOCK_EX)