sub logLine { my ($text) = @_; chomp($text); my ($package, $filename, $line) = caller; my $FunctionName = (caller(1))[3]; if (!$FunctionName) { $FunctionName = "Main"; } if ($FunctionName =~ m/::(.+)/) { $FunctionName = $1; } my $time = sprintf("%s %s %s", (split(" ", localtime))[1..3]); #do sprintf left align truncate until sprintf supports if ($files{log}{fileNameLen} =~ m/-\d+\.(\d+)/) { $filename = substr($filename, 0, $1); } if ($files{log}{funNameLen} =~ m/-\d+\.(\d+)/) { $FunctionName = substr($FunctionName, 0, $1); } my $header = sprintf("%*s, %*s, %*s, %*s:", $files{log}{timeLen}, $time, $files{log}{fileNameLen}, $filename, $files{log}{funNameLen}, $FunctionName, $files{log}{lineNumLen}, $line); #print "$header $text\n"; #only for testing $writelog->down(); print $LOGFH "$header $text\n"; $writelog->up();