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

Refactorized the code #9

Merged
merged 11 commits into from Apr 6, 2017
23 changes: 21 additions & 2 deletions CHANGELOG.md
Expand Up @@ -6,9 +6,28 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Fixed
### Changed

* Rewrited the middleware in order to be more flexible

### Removed

* The options `vhost` and `combined` are not longer available

### Added

* Write dash on empty headers
* Option `hostnameLookups` to enable this flag
* Option `format` to customize the message log format
* New constants with predefined formats:
* `AccessLog::FORMAT_COMMON`
* `AccessLog::FORMAT_COMMON_VHOST`
* `AccessLog::FORMAT_COMBINED`
* `AccessLog::FORMAT_REFERER`
* `AccessLog::FORMAT_AGENT`
* `AccessLog::FORMAT_VHOST`
* `AccessLog::FORMAT_COMMON_DEBIAN`
* `AccessLog::FORMAT_COMBINED_DEBIAN`
* `AccessLog::FORMAT_VHOST_COMBINED_DEBIAN`

## [0.5.0] - 2017-04-03

Expand Down
28 changes: 22 additions & 6 deletions README.md
Expand Up @@ -46,13 +46,25 @@ $response = $dispatcher->dispatch(new ServerRequest());

The logger object used to store the logs.

#### `combined($combined = true)`
#### `format(string $format)`

Custom format used in the log message. [More info about the available options](http://httpd.apache.org/docs/2.4/mod/mod_log_config.html). You can use also one of the following constants provided with predefined formats:
* `AccessLog::FORMAT_COMMON` (used by default)
* `AccessLog::FORMAT_COMMON_VHOST`
* `AccessLog::FORMAT_COMBINED`
* `AccessLog::FORMAT_REFERER`
* `AccessLog::FORMAT_AGENT`
* `AccessLog::FORMAT_VHOST`
* `AccessLog::FORMAT_COMMON_DEBIAN`
* `AccessLog::FORMAT_COMBINED_DEBIAN`
* `AccessLog::FORMAT_VHOST_COMBINED_DEBIAN`

To use the *Combined Log* format instead the *Common Log* format. The *Combined Log* format is exactly the same than *Common Log,* with the addition of two more fields: `Referer` and `User-Agent` headers.

#### `vhost($vhost = true)`

To prepend the virtual host info to the log record. [more info](https://httpd.apache.org/docs/2.4/logs.html#virtualhost)
```php
$dispatcher = new Dispatcher([
(new Middlewares\AccessLog($logger))
->format(Middlewares\AccessLog::FORMAT_COMMON_VHOST)
]);
```

#### `ipAttribute(string $ipAttribute)`

Expand All @@ -69,6 +81,10 @@ $dispatcher = new Dispatcher([
]);
```

#### `hostnameLookups(bool $hostnameLookups = true)`

Enable the `hostnameLookups` flag used to get the remote hostname (`%h`). (false by default)

---

Please see [CHANGELOG](CHANGELOG.md) for more information about recent changes and [CONTRIBUTING](CONTRIBUTING.md) for contributing details.
Expand Down