1.2.0 • Published 2 years ago

rest-api-logger v1.2.0

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

Installation

Compatible with Any Node JS

Required Node fs library for file operations.

npm i rest-api-logger

Rest API Logger (Express JS)

Build Status

This package helps you to record logs of APIs as a middleware.

  • Secure
  • Easy to use
  • Regular Updates
  • Neat and clean code
  • Commented functions
  • Optimized Code

Features

  • Records every API log
  • Predefined Logging function
  • Predefined function to Get Logs
  • Clear Logs with
node -e require('rest-api-logger').clearLogs()

Upcoming

  • Pagination for Logs
  • Logs predefined APIs

Github Repo

Build Status https://github.com/bhavneeshgoyal99/Rest-API-Logger-Express-JS-

Sample Code

const http = require("http");
var express = require("express");
var app = express();
const fs = require("fs");

/* Importing Package */
const logger = require("loggers");

/* Adding Middleware */
app.use(logger.logger);

app.get("/", function (req, res) {
    res.json({ test: "test" });
    res.end();
});

app.get("/logs", function (req, res) {
    // Reading logs Here
    const logs = logger.readLogs();

    res.json(logs);
    res.end();
});

app.get("/clear-logs", function (req, res) {
    // Clear Logs Here
    const logs = logger.clearLogs();

    res.end();
});

const port = 4561;
app.listen(port, () => {
    console.log("server started at " + port);
});
1.2.0

2 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago