Skip to content

bhavneeshgoyal99/Rest-API-Logger-Express-JS-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published