@meteor-labs/truck-logger
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

@meteor-labs/truck-logger
Truck Logger

A minimal Express Logger built with Winston.

InstallationHow to use

Installation

  1. Install package
    # using npm
    npm i @meteor-labs/truck-logger
    # using yarn
    yarn add @meteor-labs/truck-logger
  2. 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:

ss_1

ss_2

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..')
  
  ...
};

Screenshot 2022-12-30 at 16 04 08

Credits

This package uses the following open source packages:

Support

Buy Me A Coffee

Package Sidebar

Install

npm i @meteor-labs/truck-logger

Weekly Downloads

0

Version

1.3.0

License

MIT

Unpacked Size

21.8 kB

Total Files

21

Last publish

Collaborators

  • riodewanto
  • aslam.hafidz
  • asuramus