1.1.1 • Published 3 years ago

simple-logger-in-js v1.1.1

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

Simple-Logger In NodeJS😃

Custom Logger In Javascript Runtime Environment (also TS)

It's Most Simple of Simple!

Installation

$ npm install node-custom-logger

Example In Koa.js

import Koa from "koa";
import Router from "koa-router";
import bodyParser from "koa-bodyparser";
import cors from "@koa/cors";
import SimpleLogger from "simple-logger-in-js";

const app = new Koa();
const router = new Router();
const port = 3000;

app.use(cors());
app.use(async (ctx, next) => {
  SimpleLogger(
    { host: ctx.host },
    "[DEBUG] ${options.now} User Connected Host : ${options.host}"
  );
  next();
});
app.use(bodyParser());
app.use(router.routes);

app.listen(port, () => console.log("koa server loading..."));

😃 OutPut

image

Other Example In Debugging Request

import Koa from "koa";
import Router from "koa-router";
import bodyParser from "koa-bodyparser";
import cors from "@koa/cors";
import SimpleLogger from "simple-logger-in-js";

const app = new Koa();
const router = new Router();
const port = 3000;

app.use(cors());
app.use(bodyParser());
app.use(async (ctx, next) => {
  SimpleLogger(
    {
      time: new Date().toISOString(),
      host: ctx.request.URL,
      body: JSON.stringify(ctx.request.body),
    },
    "[DEBUG] ${options.time} | User Connected Host : ${options.host}" +
      "\nRequeset Body : ${options.body}"
  );
  next();
});
app.use(router.routes);

app.listen(port, () => console.log("koa server loading..."));

Output

image

1.1.1

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago