From 5a4c7a2af7bd03ff98eeee079bcd094591f855f8 Mon Sep 17 00:00:00 2001 From: Matias Pizzagalli Date: Tue, 14 May 2019 17:01:01 -0300 Subject: [PATCH] Added section to readme to migrate from winston and morgan to express-wolox-logger --- Migrate.md | 40 ++++++++++++++++++++++++++++++++++++++++ README.md | 46 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 8 ++++---- 3 files changed, 89 insertions(+), 5 deletions(-) create mode 100644 Migrate.md diff --git a/Migrate.md b/Migrate.md new file mode 100644 index 0000000..d1e6800 --- /dev/null +++ b/Migrate.md @@ -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); + } +``` diff --git a/README.md b/README.md index 13bb89d..6941a36 100644 --- a/README.md +++ b/README.md @@ -1 +1,45 @@ -# express-wolox-logger-node \ No newline at end of file +# 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. diff --git a/package.json b/package.json index 5833db6..a26b569 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "express-wolox-logger", - "version": "0.0.1", + "version": "0.0.2", "description": "ExpressJS Wolox Logger", "main": "index.js", "scripts": { @@ -8,7 +8,7 @@ }, "repository": { "type": "git", - "url": "git+ssh://git@github.com/mpizzagalli/express-logger.git" + "url": "git@github.com: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",