@meteor-labs/truck-logger
v1.3.0
Published
A minimal Express Logger.
Downloads
7
Readme
Installation
- Install package
# using npm npm i @meteor-labs/truck-logger
# using yarn yarn add @meteor-labs/truck-logger
- Add your MongoDB access to your .env
TRUCK_REQUEST_KEY= // requestId. default: truckNo TRUCK_DB_HOST= TRUCK_DB_PORT= TRUCK_DB_USER= TRUCK_DB_PASSWORD=
How To Use
To use truck-logger add truckExpress
to your API Route. Here is an example:
const { truckExpress } = require('@meteor-labs/truck-logger');
app.get('/truck/number/1', truckExpress('truck_1_collection'), ...);
// or
router.get('/truck/number/1', truckExpress('truck_1_collection'), ...);
and.. That`s it!! 🦀
As default truckExpress
will be generated request result for you, which is log console & log data on MongoDB along with default meta info inside. Like this:
Oh.. If you want to create new log with same truckNo (requestId)
. You can do this inside your controller:
const { truck } = require('@meteor-labs/truck-logger');
const truck1Controller = () => {
...
truck().info('The truck is still on its way..')
truck().warn('Almost there..')
truck().error('Oops..')
...
};
Credits
This package uses the following open source packages: