Skip to content

Commit

Permalink
Improved type conversions in string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
jbroadway committed Apr 22, 2013
1 parent 943707a commit ee93cc0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Analog/Logger.php
Expand Up @@ -112,6 +112,12 @@ private function interpolate ($message, array $context = array ()) {
foreach ($context as $key => $val) {
if (is_object ($val) && get_class ($val) === 'DateTime') {
$val = $val->format ('Y-m-d H:i:s');
} elseif (is_object ($val)) {
$val = json_encode ($val);
} elseif (is_array ($val)) {
$val = join (', ', $val);
} elseif (is_resource ($val)) {
$val = (string) $val;
}
$replace['{' . $key . '}'] = $val;
}
Expand Down

0 comments on commit ee93cc0

Please sign in to comment.