Skip to content

Commit 51006a5

Browse files
authored
Use a dedicated logging channel by default (#5)
1 parent 849eb67 commit 51006a5

4 files changed

Lines changed: 21 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased 2.0]
9+
10+
### Changed
11+
12+
- Logging will now by default be directed to the `shortcode` channel,
13+
instead of the `app` channel used previously.
14+
- Slightly reduced the logging level in `EmbeddedShortcodeHandler`.

README.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ comment:
1414
In analogy to living style guides, this bundle also provides an optional shortcode guide. This guide can be used for
1515
automated testing of your shortcodes as well.
1616

17-
1817
## Installation
1918

2019
As usual, install via [composer](https://getcomposer.org/) and register the bundle in your application:
@@ -55,7 +54,6 @@ public function registerBundles()
5554
}
5655
```
5756

58-
5957
## Usage
6058

6159
### Defining your own shortcodes
@@ -161,7 +159,6 @@ And finally a twig template like this:
161159
</div>
162160
```
163161

164-
165162
### Activating the Shortcode Guide
166163

167164
The optional shortcode guide is a controller providing an overview page of the configured shortcodes and a detail page
@@ -218,7 +215,6 @@ Finally, enrich your shortcode tags with description and example attributes for
218215
With the route prefix defined as above, call ```/shortcodes/``` to get the list of shortcodes and follow the links to the
219216
detail pages.
220217

221-
222218
### Configuration
223219

224220
In most cases, the default values should work fine. But you might want to configure something else, e.g. if the default
@@ -294,7 +290,6 @@ final class ImageTest extends ShortcodeTest
294290
}
295291
```
296292

297-
298293
## Logging
299294

300295
When something goes wrong with the resolving of a shortcode, maybe you not only want to know which shortcode with
@@ -303,9 +298,7 @@ that embedded the shortcode.
303298

304299
This is tricky is you embed your shortcode controllers via ESI, as the ESI subrequest is in Symfony terms a master
305300
request, preventing you from getting your answer from RequestStack::getMasterRequest(). Hence, the
306-
`EmbedShortcodeHandler` logs with the default monolog handler which controller it will call to resolve the shortcode.
307-
You can overwrite the `EmbedShortcodeHandler`'s logger, e.g. if you want to change the channel, in the service
308-
definition of your shortcode:
301+
`EmbedShortcodeHandler` logs this information in the `shortcode` channel.
309302

310303
```xml
311304
<!-- src/AppBundle/Resources/config/shortcodes.xml -->
@@ -323,12 +316,11 @@ definition of your shortcode:
323316
</container>
324317
```
325318

326-
327319
## Credits, Copyright and License
328320

329321
This bundle was started at webfactory GmbH, Bonn.
330322

331-
- <http://www.webfactory.de>
332-
- <http://twitter.com/webfactory>
323+
- <https://www.webfactory.de>
324+
- <https://twitter.com/webfactory>
333325

334-
Copyright 2018 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).
326+
Copyright 2018-2021 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).

src/Handler/EmbeddedShortcodeHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(
5656
*/
5757
public function __invoke(ShortcodeInterface $shortcode)
5858
{
59-
$this->logger->notice(
59+
$this->logger->info(
6060
'Request {controllerName} with parameters {parameters} and renderer {renderer} to resolve shortcode {shortcode}, triggered by a request to {url}.',
6161
[
6262
'controllerName' => $this->controllerName,

src/Resources/config/shortcodes.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<argument>esi</argument>
4343
<argument type="service" id="request_stack" />
4444
<argument type="service" id="logger" on-invalid="null" />
45+
<tag name="monolog.logger" channel="shortcode" />
4546
</service>
4647

4748
<!-- alias for BC -->
@@ -54,6 +55,7 @@
5455
<argument>inline</argument>
5556
<argument type="service" id="request_stack" />
5657
<argument type="service" id="logger" on-invalid="null" />
58+
<tag name="monolog.logger" channel="shortcode" />
5759
</service>
5860

5961
<!-- alias for BC -->

0 commit comments

Comments
 (0)