[pmg-devel] [PATCH pmg-api] limit precision of bayes-score in log

Stoiko Ivanov s.ivanov at proxmox.com
Wed May 22 17:31:52 CEST 2019


Spamassassin's bayes_score is a float, and is written to the log during
filtering. Limiting the precision for the log to 2 decimal places keeps
logs a bit shorter and also prevents misreadings of values like:
5.55111571207834e-17

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
This particular number confused us today while handling a support-ticket.

 PMG/RuleDB/Spam.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/PMG/RuleDB/Spam.pm b/PMG/RuleDB/Spam.pm
index feda0f3..97a80b3 100644
--- a/PMG/RuleDB/Spam.pm
+++ b/PMG/RuleDB/Spam.pm
@@ -421,8 +421,8 @@ sub analyze_spam {
 	    $sa_max = $status->get_required_score();
 	    $autolearn = $status->get_autolearn_status();
 
-	    $bayes = defined($status->{bayes_score}) ? 
-		$status->{bayes_score} : "undefined";
+	    $bayes = defined($status->{bayes_score}) ?
+		sprintf('%0.2f', $status->{bayes_score}) : "undefined";
 
 	    my $salist = $status->get_names_of_tests_hit();
 
-- 
2.11.0




More information about the pmg-devel mailing list