lambda-lite-logger

📝 Yet another logger

Usage no npm install needed!

<script type="module">
  import lambdaLiteLogger from 'https://cdn.skypack.dev/lambda-lite-logger';
</script>

README

Lambda lite logger

NPM Version NPM Downloads License

📝 Yet another logger for Lambda

Why

I just want to pretty print any nest object param from log with some color..., nothing fancy.

Installation

npm i lambda-lite-logger

Usage

Basic

import { Logger } from "lambda--lite-logger";

const logger = new Logger();

// Pretty print nest object with 2 space by default
// 2021-1-6 19:31:6 [INFO] some data {
//   a: [
//     {
//       b: 1,
//       c: {
//         d: 2
//       }
//     }
//   ]
// }
logger.info("some data", { a: [{ b: 1, c: { d: 2 } }] });

More

const logger = new Logger({
  prettyPrint: false, // turn off prettyPrint, defaults to true
});

logger.debug("Only log process.env.NODE_ENV is not production"); // [DEBUG] ...
logger.warn("Warning"); // [WARN] warning
logger.error("Oh no"); // [ERROR] Oh no

logger.log("info", "low level API, just equal logger.info"); // [INFO] ...