Logger: Fix substitution of exception messages

This commit is contained in:
Johannes Meyer 2015-05-13 10:46:34 +02:00
parent f93c2de6be
commit 0a387573f3
2 changed files with 6 additions and 4 deletions

View File

@ -243,7 +243,9 @@ class Logger
return vsprintf(
array_shift($arguments),
array_map(
function ($a) { return is_string($a) ? $a : json_encode($a); },
function ($a) {
return is_string($a) ? $a : ($a instanceof Exception ? $a->getMessage() : json_encode($a));
},
$arguments
)
);

View File

@ -56,7 +56,7 @@ class Manager
} catch (NotReadableError $e) {
Logger::error(
new IcingaException(
'Cannot load preferences for user "%s". An exception was thrown',
'Cannot load preferences for user "%s". An exception was thrown: %s',
$username,
$e
)
@ -74,7 +74,7 @@ class Manager
} catch (NotReadableError $e) {
Logger::error(
new IcingaException(
'Cannot load preferences for user "%s". An exception was thrown',
'Cannot load preferences for user "%s". An exception was thrown: %s',
$username,
$e
)
@ -92,7 +92,7 @@ class Manager
$groupsFromBackend = $groupBackend->getMemberships($user);
} catch (Exception $e) {
Logger::error(
'Can\'t get group memberships for user \'%s\' from backend \'%s\'. An exception was thrown:',
'Can\'t get group memberships for user \'%s\' from backend \'%s\'. An exception was thrown: %s',
$username,
$name,
$e