8000 merged branch stof/loggerinterface (PR #1356) · brki/symfony@1c14010 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1c14010

Browse files
committed
merged branch stof/loggerinterface (PR symfony#1356)
Commits ------- 72d0ebe [WebProfilerBundle] Added the support of the the logging context in the template 410b3e0 [HttpKernel] Added the context in the LoggerInterface Discussion ---------- context in the LoggerInterface This adds the context in the LoggerInterface. The change is totally BC for people using the logger. However this affects people implementing the interface. Note that this require Seldaek/monolog#33 for the implementation --------------------------------------------------------------------------- by Seldaek at 2011/06/17 04:24:18 -0700 @fabpot: just ping me when you are merging this one, so I can merge in monolog and we avoid out-of-sync issues. --------------------------------------------------------------------------- by stof at 2011/06/17 04:49:05 -0700 @Seldaek you can merge in Monolog when you want. Monolog is BC so merging it before the PR in Symfony2 does not break things. --------------------------------------------------------------------------- by Seldaek at 2011/06/17 05:08:34 -0700 Ah right, I thought the interfaces wouldn't match, but PHP allows extra args it seems so I'll merge right now. --------------------------------------------------------------------------- by stof at 2011/06/17 05:32:58 -0700 PHP allows extra *optionnal* args and it is the case here :) --------------------------------------------------------------------------- by Seldaek at 2011/06/17 05:35:00 -0700 Well yes otherwise you break the interface. Anyway it's merged so @fabpot, anytime :)
2 parents 3f70fc1 + 72d0ebe commit 1c14010

File tree

6 files changed

+32
-24
lines changed

6 files changed

+32
-24
lines changed

src/Symfony/Bridge/Monolog/Handler/DebugHandler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function getLogs()
3434
'message' => $record['message'],
3535
'priority' => $record['level'],
3636
'priorityName' => $record['level_name'],
37+
'context' => $record['context'],
3738
);
3839
}
3940

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/logger.html.twig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
{% for log in collector.logs %}
3333
<li class="{{ cycle(['odd', 'even'], loop.index) }}{% if 'ERR' == log.priorityName or 'ERROR' == log.priorityName %} error{% endif %}">
3434
{{ log.message }}
35+
{% if log.context is defined and log.context is not empty %}
36+
<br />
37+
<small>
38+
<strong>Context</strong>: {{ log.context|yaml_encode }}
39+
</small>
40+
{% endif %}
3541
</li>
3642
{% endfor %}
3743
</ul>

src/Symfony/Component/HttpKernel/Log/DebugLoggerInterface.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface DebugLoggerInterface
2323
*
2424
* A log is an array with the following mandatory keys:
2525
* timestamp, message, priority, and priorityName.
26+
* It can also have an optionnal context key containing an array.
2627
*
2728
* @return array An array of logs
2829
*/

src/Symfony/Component/HttpKernel/Log/LoggerInterface.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
*/
1919
interface LoggerInterface
2020
{
21-
function emerg($message);
21+
function emerg($message, array $context = array());
2222

23-
function alert($message);
23+
function alert($message, array $context = array());
2424

25-
function crit($message);
25+
function crit($message, array $context = array());
2626

27-
function err($message);
27+
function err($message, array $context = array());
2828

29-
function warn($message);
29+
function warn($message, array $context = array());
3030

31-
function notice($message);
31+
function notice($message, array $context = array());
3232

33-
function info($message);
33+
function info($message, array $context = array());
3434

35-
function debug($message);
35+
function debug($message, array $context = array());
3636
}

src/Symfony/Component/HttpKernel/Log/NullLogger.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,19 @@
2020
*/
2121
class NullLogger implements LoggerInterface
2222
{
23-
public function emerg($message) {}
23+
public function emerg($message, array $context = array()) {}
2424

25-
public function alert($message) {}
25+
public function alert($message, array $context = array()) {}
2626

27-
public function crit($message) {}
27+
public function crit($message, array $context = array()) {}
2828

29-
public function err($message) {}
29+
public function err($message, array $context = array()) {}
3030

31-
public function warn($message) {}
31+
public function warn($message, array $context = array()) {}
3232

33-
public function notice($message) {}
33+
public function notice($message, array $context = array()) {}
3434

35-
public function info($message) {}
35+
public function info($message, array $context = array()) {}
3636

37-
public function debug($message) {}
37+
public function debug($message, array $context = array()) {}
3838
}

tests/Symfony/Tests/Component/HttpKernel/Logger.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,42 @@ public function log($message, $priority)
4646
$this->logs[$priority][] = $message;
4747
}
4848

49-
public function emerg($message)
49+
public function emerg($message, array $context = array())
5050
{
5151
$this->log($message, 'emerg');
5252
}
5353

54-
public function alert($message)
54+
public function alert($message, array $context = array())
5555
{
5656
$this->log($message, 'alert');
5757
}
5858

59-
public function crit($message)
59+
public function crit($message, array $context = array())
6060
{
6161
$this->log($message, 'crit');
6262
}
6363

64-
public function err($message)
64+
public function err($message, array $context = array())
6565
{
6666
$this->log($message, 'err');
6767
}
6868

69-
public function warn($message)
69+
public function warn($message, array $context = array())
7070
{
7171
$this->log($message, 'warn');
7272
}
7373

74-
public function notice($message)
74+
public function notice($message, array $context = array())
7575
{
7676
$this->log($message, 'notice');
7777
}
7878

79-
public function info($message)
79+
public function info($message, array $context = array())
8080
{
8181
$this->log($message, 'info');
8282
}
8383

84-
public function debug($message)
84+
public function debug($message, array $context = array())
8585
{
8686
$this->log($message, 'debug');
8787
}

0 commit comments

Comments
 (0)
0