-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Wolox/how-to-migrate
Added section to readme to migrate from winston
- Loading branch information
Showing
3 changed files
with
89 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## Migrate from winston to express-wolox-logger | ||
|
||
If you need to migrate from wolox express-js boostrap configuration with winston to this package follow the following steps: | ||
|
||
1. Remove your winston dependencies | ||
2. Run `npm i express-wolox-logger` | ||
3. Go to `app/logger/index.js` and replace the whole file for: | ||
``` | ||
const { logger } = require('express-wolox-logger'); | ||
module.exports = logger; | ||
``` | ||
### Optionals | ||
If you want to use the new requestMiddleware provided by this package instead of morgan's middleware follow the following steps: | ||
|
||
4. Remove your morgan dependencies | ||
5. Go to `app.js` | ||
6. Add the following line at the very start of the file: | ||
``` | ||
const { expressMiddleware, expressRequestIdMiddleware } = require('express-wolox-logger'); | ||
``` | ||
7. Find where you have the following code (or something very similar): | ||
``` | ||
if (!config.isTesting) { | ||
morgan.token('req-params', req => JSON.stringify(req.params)); | ||
app.use( | ||
morgan( | ||
'[:date[clf]] :remote-addr - Request ":method :url" with params: :req-params. Response status: :status. Elapsed time: :response-time' | ||
) | ||
); | ||
} | ||
``` | ||
and replace it with: | ||
``` | ||
app.use(expressRequestIdMiddleware); | ||
if (!config.isTesting) { | ||
app.use(expressMiddleware); | ||
} | ||
``` |
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 +1,45 @@ | ||
# express-wolox-logger-node | ||
# Express Wolox Logger | ||
|
||
ExpressJS logger that wraps [pino](https://github.com/pinojs/pino) with additional features like unique requestId and a requestMiddleware. | ||
|
||
## Migrate from winston to express-wolox-logger | ||
If you are wondering how to migrate from wolox express-js boostrap configuration with winston to this package refer to the [step by step migration guide](Migrate.md) | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Run the tests (`npm test`) | ||
4. Commit your changes (`git commit -am 'Add some feature'`) | ||
5. Push to the branch (`git push origin my-new-feature`) | ||
6. Create new Pull Request | ||
|
||
## About | ||
|
||
This project is maintained by [Wolox](https://github.com/wolox) and it was written by [Wolox](http://www.wolox.com.ar). | ||
|
||
![Wolox](https://raw.githubusercontent.com/Wolox/press-kit/master/logos/logo_banner.png) | ||
|
||
## License | ||
|
||
**express-wolox-logger** is available under the MIT [license](LICENSE.md). | ||
|
||
Copyright (c) 2019 Wolox | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,14 +1,14 @@ | ||
{ | ||
"name": "express-wolox-logger", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "ExpressJS Wolox Logger", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/mpizzagalli/express-logger.git" | ||
"url": "[email protected]:Wolox/express-wolox-logger.git" | ||
}, | ||
"keywords": [ | ||
"express", | ||
|
@@ -22,9 +22,9 @@ | |
"author": "Wolox", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/mpizzagalli/express-logger/issues" | ||
"url": "https://github.com/Wolox/express-wolox-logger/issues" | ||
}, | ||
"homepage": "https://github.com/mpizzagalli/express-logger#readme", | ||
"homepage": "https://github.com/Wolox/express-wolox-logger#readme", | ||
"dependencies": { | ||
"cls-hooked": "^4.2.2", | ||
"on-finished": "^2.3.0", | ||
|