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

Thomas Lamprecht t.lamprecht at proxmox.com
Thu May 23 09:21:02 CEST 2019


On 5/22/19 5:31 PM, Stoiko Ivanov wrote:
> 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";

applied, but it's now a bit of a borderline complex ternary expression..
Next time maybe switch it to something


$bayes = "undefined";
if (defined(my $score = $status->{bayes_score})) {
    $bayes = sprintf('%0.2f', $score);
}

but I don't want to bikeshed to much, it does what it says, so thanks!

>  
>  	    my $salist = $status->get_names_of_tests_hit();
>  
> 



More information about the pmg-devel mailing list