1.0.1 • Published 2 years ago

quick-logger-be v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

quick-logger-be

npm NPM

Quick-logger-be is a tool that allows developers to quickly add a logger to gather information from their backend application.

Features:

  • Pre-configured logger
  • Ability to set the log level and messages
  • Logs that are output to the console, written to a file, and sent to a user-provided API endpoint

Getting Started

Installation

npm i quick-logger-be

Additional Set-up

In order to send your logs to an API, you will need to provide the desired API endpoint.

Create a .env file in the root directory. See the .env.Example file for formatting.

.env file:

LOGS_API_ENDPOINT= //insert API endpoint here

If you are using Webpack v.5 or later, you might also need to install the node-polyfill-webpack-plugin.

Install the package:

npm install node-polyfill-webpack-plugin

Add the plugin to your webpack.config file. Example:

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  \\Other rules...
  plugins: [
    new NodePolyfillPlugin()
  ]
};

Usage

Configure the logger and transports.

Example:

const { loggerBeConfig } = require('quick-logger-be');

app.use(loggerBeConfig());

Add the logger into your application in the places where you want to trigger a log.

Customize the message and log level (info, debug, warn, error).

Example:

const { logger } = require('quick-logger-be');

myFunctionToWatch () => {
  //do something
  logger.info(//message string);
  logger.debug(//message string)
  logger.warn(//message string)
  logger.error(//message string)
}

Contributions

Contributing to the project: See the Github repo

Acknowledgements

Built with:

Authors:

License

Distributed under the MIT License

1.0.1

2 years ago

1.0.0

2 years ago

0.1.0

2 years ago