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

Added documentation on how to fix browser console logging components. #289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,22 @@ $this->sharedData()->get('myvar') // Access stored service variables
echo $this->query(array('page' => 2)) // Modify the current query string
```

## Headers Integration With Logging Services

Logging services that send info to the browser console may fail when used with
Klein. They use HTTP headers for their data and need to send them ahead of when
Klein does. Klein provides a method to help with this: `$klein->afterDispatch($callable)`.

Here is an example for the `BrowserConsoleHandler` from [Monolog](https://github.com/Seldaek/monolog),
though a similar pattern should work its `ChromePHPHandler` or `PHPConsoleHandler`.

```php
$log = new Monolog\Logger('debug');
$log->pushHandler(new Monolog\Handler\BrowserConsoleHandler());

$klein->afterDispatch(['\Monolog\Handler\BrowserConsoleHandler', 'send']);
```

## API

Below is a list of the public methods in the common classes you will most likely use. For a more formal source
Expand Down