From 43d54cd9aa848e6e8b6b5fd383429659c33955b9 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Fri, 3 Aug 2018 15:47:52 +0200
Subject: [PATCH] more consistency in log messages

---
 lib/AccountManager/App.pm | 42 +++++++++++----------------------------
 1 file changed, 12 insertions(+), 30 deletions(-)

diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index 4f00dd1..6d63b81 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -303,7 +303,7 @@ sub req_select_email {
         my $entities = $metadata->parse(id => $entityid);
         my $entity = $entities->[0];
         $self->abort(
-            log  => sprintf("No such SP '%s' in metadata", $entityid),
+            log  => "No such SP $entityid in metadata",
             user => "no_such_entity"
         ) if !$entity;
 
@@ -314,7 +314,7 @@ sub req_select_email {
 
         # save in DB
         $self->abort(
-            log  => "Failed to save service provider object",
+            log  => "Failed to save service provider",
             user => "internal"
         ) if !$sp->save();
     }
@@ -378,11 +378,7 @@ sub req_complete_challenge {
 
     ## Check that email is a known contact for this SP
     $self->abort(
-        log  => sprintf(
-            "Requested a token for %s for an unautorized address '%s'",
-            $entityid,
-            $email
-        ),
+        log  => "Requested a token for SP $entityid with unautorized address $email",
         user => "internal",
     ) if !$provider->is_contact($email);
 
@@ -395,7 +391,7 @@ sub req_complete_challenge {
 
     if ($old_token->load(speculative => 1)) {
         $self->abort(
-            log  => sprintf("Failed to delete previous authentication token with ID %s", $old_token->id()),
+            log  => "Failed to delete old authentication token",
             user => "internal"
         ) if !$old_token->delete();
     }
@@ -414,7 +410,7 @@ sub req_complete_challenge {
     );
 
     $self->abort(
-        log  => "Failed to save service authentication token",
+        log  => "Failed to save creation authentication token",
         user => "internal"
     ) if !$token->save();
 
@@ -560,10 +556,7 @@ sub req_create_accounts {
     }
 
     $self->abort(
-        log  => sprintf(
-            "Failed to create test accounts for SP with entityid %s",
-            $entityid
-        ),
+        log  => "Failed to create test accounts for SP $entityid",
         user => "accounts_creation_failure"
     ) if !@accounts;
 
@@ -578,11 +571,8 @@ sub req_create_accounts {
         );
     };
     $self->abort(
-        log  => sprintf(
-            "Failed to create simpleSAMLphp configuration file: %s",
-            $EVAL_ERROR
-        ),
-        user => "accounts_creation_failed"
+        log  => "Failed to create simpleSAMLphp configuration file: $EVAL_ERROR",
+        user => "accounts_creation_failure"
     ) if $EVAL_ERROR;
 
     $self->{logger}->infof(
@@ -692,8 +682,8 @@ sub get_parameter {
 
     if ($patterns{$name}) {
         $self->abort(
-            log  => "Incorrect parameter format: entityid",
-            user => "format_entityid"
+            log  => "Incorrect parameter format: $name",
+            user => "format_$name"
         ) if $value !~ $patterns{$name};
     }
 
@@ -726,20 +716,12 @@ sub check_token {
     );
 
     $self->abort(
-        log => sprintf(
-            "Failed to validate authentication token %s for entityid %s",
-            $secret,
-            $args{entityid}
-        ),
+        log  => "No such authentication token $secret",
         user => "wrong_token"
     ) if !$token->load(speculative => 1);
 
     $self->abort(
-        log => sprintf(
-            "Authentication token %s cannot be used for SP with entityid %s",
-            $secret,
-            $args{entityid}
-        ),
+        log  => "Authentication token $secret cannot be used for SP $args{entityid}",
         user => "wrong_token_for_sp"
     ) if $token->sp_entityid() ne $args{entityid};
 
-- 
GitLab