@ntf/logger
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

@ntf/logger

Another console logger library

Why

Because I like reinventing the wheel :)

Installation

Use your favourite package manager, idk

npm install @ntf/logger
yarn add @ntf/logger
pnpm install @ntf/logger

Usage

Importing

This library can be used in CommonJS and ESModule environments

const { ... } = require("@ntf/logger");
import { ... } from "@ntf/logger";

Creating a logger

You can use createLogger to create a logger based on the runtime you are using (browser, server, etc.)

const logger = createLogger("MyLoggerName")

But you can use the implementations directly if you want

For servers

For servers there's AnsiLogger class which you can guess, uses escaped ansi code for colors in termnial/console/command prompt/whatever terminal name

For browsers

For browsers there's CSSLogger class which uses the cool feature of CSS styling, you can try AnsiLogger but on some browsers it looks weird (especially Chrome)

I want to make my own Logger

Just extend the Logger class and implement print:

class MyCoolAndAwesomeLogger extends Logger
{
    // level = can be "info", "warn", "error", "debug" or "trace"
    // args = well... anything... literally
    print(level,...args)
    {
        // do some funny stuff here
    }
};

License stuff that nobody reads

Just like any Open Source Project this has a License, the MIT License

Package Sidebar

Install

npm i @ntf/logger

Weekly Downloads

0

Version

1.1.0

License

MIT

Unpacked Size

28.3 kB

Total Files

7

Last publish

Collaborators

  • n1ghtthef0x