-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor - rewritten tests - replaced lodash.omit with ramda to unify middlewares - stopped using event.requestContext - added NPM keywords - added README.md * 0.1.0 * Update snapshot * Mock perf_hooks module Co-authored-by: Wojciech Iskra <[email protected]>
- Loading branch information
Showing
6 changed files
with
193 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
# middy-access-log | ||
Middy middleware for logging processed requests in an access-log like fashion | ||
# Schibsted Middy access log middleware | ||
|
||
#### Access log middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda | ||
|
||
|
||
This middleware logs processed requests in an access log like fashion. | ||
I suggest using it together with [@schibsted/middy-error-handler](https://github.com/schibsted/middy-error-handler) | ||
|
||
This access log is optimised for JSON loggers e.g. [bunyan](https://github.com/trentm/node-bunyan) or [pino](https://getpino.io/) | ||
|
||
Sets headers in `after` and `onError` phases. | ||
|
||
|
||
## Install | ||
|
||
To install this middleware you can use NPM: | ||
|
||
```bash | ||
npm install --save @schibsted/middy-access-log | ||
``` | ||
|
||
|
||
## Options | ||
|
||
- `logger` (defaults to `console`) - a logging function that is invoked with the current error as an argument. You can pass `false` if you don't want the logging to happen. | ||
- `level` (defaults to `info`) - log level to use for the log entries | ||
|
||
|
||
See the sample usage below. | ||
|
||
|
||
## Sample usage | ||
|
||
```javascript | ||
const middy = require('@middy/core'); | ||
const accessLog = require('@schibsted/middy-access-log'); | ||
|
||
const handler = middy(async () => ({ | ||
statusCode: 200, | ||
body: JSON.stringify({ foo: 'bar' }), | ||
})); | ||
|
||
handler | ||
.use(accessLog()); | ||
``` | ||
|
||
|
||
## Contributing | ||
|
||
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/schibsted/middy-access-log/issues) or to [submit Pull Requests](https://github.com/schibsted/middy-access-log/pulls). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.