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

1.4.0 • Public • Published

Spark Logger

A logger built on TypeScript

Installation

  • To install, run npm i @spark.ts/logger.
  • Usage:

Example Usage

TypeScript / ESM

import { Logger } from '@spark.ts/logger';

const logger = new Logger();
logger.error('An error occured');

CommonJS

const { Logger } = require('@spark.ts/logger');

const logger = new Logger();
logger.error('An error occured');

NOTE: You can use all of the functions from the regular console, such as console.log('hello world') becomes logger.log('hello world')

Types

  • There are built-in type declarations, the options for new Logger(); are below:
new Logger({
  logLevel: 'success' | 'error' | 'warn' | 'info' | 'debug', // Defaults to 'debug'
  logStyle: 'highlight' | 'bracket', // Defaults to 'highlight'

  // Optional custom messages for the logger. Use {msg} to represent the thing being logged
  messages: {
    success: 'SUCCESS: {msg}',
    error: 'ERROR: {msg}',
    warn: 'WARN: {msg}',
    info: 'INFO: {msg}',
    debug: 'DEBUG: {msg}',
  }
});

Images

Highlight Style:

Bracket Style:

Readme

Keywords

Package Sidebar

Install

npm i @spark.ts/logger

Weekly Downloads

2

Version

1.4.0

License

MIT

Unpacked Size

15.6 kB

Total Files

9

Last publish

Collaborators

  • durocodes