Chavetasoft Simple Logger

This is a simple logger for Node.js. It has only one parameter and can enable or disable the file log writer. If you enable it, the file log will be saved in the root of the project with the name log.json. Whether the file log writer is enabled or disabled, the console log will always be enabled. Fast setup and easy to use, just two lines of code. 😊🚀

Installation

npm install chavetasoft-simple-logger

Usage JavaScript

const express = require("express");
const chavetasoftLogger = require("chavetasoft-simple-logger");

const app = express();

app.use(chavetasoftLogger(true)); /*
true Enable the file log writer, 
false Disable the file log writer.
or you can use logger() without parameter
to disable the file log writer as default
*/


app.get("/", (req, res) => {
  res.send("Hello World");
});

app.listen(3000, () => {
  console.log("Server is running on port 3000");
});

Usage TypeScript

import express, { Express, Request, Response } from "express";
import chavetasoftLogger from "chavetasoft-simple-logger";

const app: Express = express();
app.use(chavetasoftLogger(true));/*
true Enable the file log writer, 
false Disable the file log writer.
or you can use logger() without parameter
to disable the file log writer as default
*/

app.get("/", (req, res) => {
res.send("Hello World");
});

app.listen(3000, () => {
console.log("Server is running on port 3000");
});

Console Output

Captura de pantalla 2024-02-27 a la(s) 22 21 48

File Log Output

[
  {
    "method": "GET",
    "url": "/65758485",
    "date": "2024-02-26T01:57:21.094Z",
    "ip": "::ffff:127.0.0.1",
    "status": 404
  }
]

License

MIT

Author

Chavetasoft

Version

0.2.0