[pmg-devel] [RFC pmg-api 2/2] Use fixed width for rule-score logging.

Stoiko Ivanov s.ivanov at proxmox.com
Fri Feb 8 11:11:50 CET 2019


Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 PMG/RuleDB/Spam.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/PMG/RuleDB/Spam.pm b/PMG/RuleDB/Spam.pm
index 987b85d..27d9865 100644
--- a/PMG/RuleDB/Spam.pm
+++ b/PMG/RuleDB/Spam.pm
@@ -351,11 +351,12 @@ sub analyze_spam {
 
     if (my $hit = $queue->{clamav_heuristic}) {
 	my $score = $queue->{clamav_heuristic_score};
+	my $logscore = sprintf('%.3f', $score);
 	my $descr = "ClamAV heuristic test: $hit";
 	my $rule = 'ClamAVHeuristics';
 	$sa_score += $score;
 	$list .= $list ? ",$rule" : $rule;
-	$loglist .= $loglist ? ",$rule($score)" : "$rule($score)";
+	$loglist .= $loglist ? ",$rule($logscore)" : "$rule($logscore)";
 	push @$sa_scores, { score => $score, rule => $rule, desc => $descr };
     }
 
@@ -418,7 +419,8 @@ sub analyze_spam {
 	    foreach my $rule (split (/,/, $salist)) {
 		$list .= $list ? ",$rule" : $rule;
 		my $score = $status->{conf}->{scores}->{$rule};
-		$loglist .= $loglist ? ",$rule($score)" : "$rule($score)";
+		my $logscore = sprintf('%.3f', $score);
+		$loglist .= $loglist ? ",$rule($logscore)" : "$rule($logscore)";
 		my $desc = $status->{conf}->get_description_for_rule($rule);
 		push @$sa_scores, { score => $score, rule => $rule, desc => $desc };
 	    }
-- 
2.11.0




More information about the pmg-devel mailing list