Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a dedicated logging channel by default #5

Merged
merged 2 commits into from
Oct 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased 2.0]

### Changed

- Logging will now by default be directed to the `shortcode` channel,
instead of the `app` channel used previously.
- Slightly reduced the logging level in `EmbeddedShortcodeHandler`.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ comment:
In analogy to living style guides, this bundle also provides an optional shortcode guide. This guide can be used for
automated testing of your shortcodes as well.


## Installation

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


## Usage

### Defining your own shortcodes
Expand Down Expand Up @@ -161,7 +159,6 @@ And finally a twig template like this:
</div>
```


### Activating the Shortcode Guide

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


### Configuration

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


## Logging

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

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

```xml
<!-- src/AppBundle/Resources/config/shortcodes.xml -->
Expand All @@ -323,12 +316,11 @@ definition of your shortcode:
</container>
```


## Credits, Copyright and License

This bundle was started at webfactory GmbH, Bonn.

- <http://www.webfactory.de>
- <http://twitter.com/webfactory>
- <https://www.webfactory.de>
- <https://twitter.com/webfactory>

Copyright 2018 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).
Copyright 2018-2021 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).
2 changes: 1 addition & 1 deletion src/Handler/EmbeddedShortcodeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(
*/
public function __invoke(ShortcodeInterface $shortcode)
{
$this->logger->notice(
$this->logger->info(
'Request {controllerName} with parameters {parameters} and renderer {renderer} to resolve shortcode {shortcode}, triggered by a request to {url}.',
[
'controllerName' => $this->controllerName,
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/config/shortcodes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<argument>esi</argument>
<argument type="service" id="request_stack" />
<argument type="service" id="logger" on-invalid="null" />
<tag name="monolog.logger" channel="shortcode" />
</service>

<!-- alias for BC -->
Expand All @@ -54,6 +55,7 @@
<argument>inline</argument>
<argument type="service" id="request_stack" />
<argument type="service" id="logger" on-invalid="null" />
<tag name="monolog.logger" channel="shortcode" />
</service>

<!-- alias for BC -->
Expand Down