Skip to content

Commit fcc67c9

Browse files
committed
docs(logging): add placeholders for dynamic data
1 parent cfadf43 commit fcc67c9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

logging.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ To log a message, inject the default logger in your controller or service::
3232
$logger->info('I just got the logger');
3333
$logger->error('An error occurred');
3434

35+
// log messages can also contain placeholders (wrap the placeholder name with braces)
36+
// these placeholders are useful for logging tools, which can aggregate log messages
37+
// that are the same except for some variable values inside them, for translation
38+
// systems in order to create localized messages, and for security because escaping
39+
// can then be done by the implementation in a context-aware fashion
40+
$logger->debug('User {userId} has logged in', [
41+
'userId' => $this->getUserId(),
42+
]);
43+
3544
$logger->critical('I left the oven on!', [
3645
// include extra "context" info in your logs
3746
'cause' => 'in_hurry',

0 commit comments

Comments
 (0)