advanced-log

1.0.1 • Public • Published

Advanced-log

About

A module dedicated to organised, clean, simple logging. | Written in TypeScript.


Installation

npm i advanced-log

Usage

Simple Warn Log

import AdvancedLog from 'advanced-log';
 
const log = new AdvancedLog({
  persistColor: '#ff0000', // Red Hex Color Code
});
 
log.warn('Hello World!');
// Logs '[ WARN ] | MM/DD/YYYY, H:MM:SS AM/PM | Hello World!' in native Orange warn() color.
 
log.warn('Hello World!', true);
// Logs '[ WARN ] | MM/DD/YYYY, H:MM:SS AM/PM | Hello World!' in persistColor #ff0000 color.

Using Custom Logs

import AdvancedLog from 'advanced-log';
 
const log = new AdvancedLog({});
 
const logNewEmail = (emailContent: string): void => {
  log.custom({
    name: 'new email',
    content: emailContent,
    color: '#b5b5b5',
  });
};
 
logNewEmail('Hello World!');
// Logs '[ NEW EMAIL ] | MM/DD/YYYY, H:MM:SS AM/PM | Hello World!' in specified #b5b5b5 color.

Documentation

Basic Logs

  error!: (content: string, persist?: boolean) => void;

Parameters:

  • Content: Content to display in the error log. (String)
  • Persist?: Whether the persistColor will be used or not. (Boolean, defaults to false.)

Usage:

  • new AdvancedLog({}).error()
  warn!: (content: string, persist?: boolean) => void;

Parameters:

  • Content: Content to display in the warn log. (String)
  • Persist?: Whether the persistColor will be used or not. (Boolean, defaults to false.)

Usage:

  • new AdvancedLog({}).warn()
  info!: (content: string, persist?: boolean) => void;

Parameters:

  • Content: Content to display in the info log. (String)
  • Persist?: Whether the persistColor will be used or not. (Boolean, defaults to false.)

Usage:

  • new AdvancedLog({}).info()
  debug!: (content: string, persist?: boolean) => void;

Parameters:

  • Content: Content to display in the debug log. (String)
  • Persist?: Whether the persistColor will be used or not. (Boolean, defaults to false.)

Usage:

  • new AdvancedLog({}).debug()
  log!: (content: string, persist?: boolean) => void;

Parameters:

  • Content: Content to display in the log. (String)
  • Persist?: Whether the persistColor will be used or not. (Boolean, defaults to false.)

Usage:

  • new AdvancedLog({}).log()
  plus!: (content: string, persist?: boolean) => void;

Parameters:

  • Content: Content to display in the plug log. (String)
  • Persist?: Whether the persistColor will be used or not. (Boolean, defaults to false.)

Usage:

  • new AdvancedLog({}).plug()
  minus!: (content: string, persist?: boolean) => void;

Parameters:

  • Content: Content to display in the minus log. (String)
  • Persist?: Whether the persistColor will be used or not. (Boolean, defaults to false.)

Usage:

  • new AdvancedLog({}).minus()

Custom Logs

  interface Specifications {
    name: string;
    content: string;
    color?: string;
  }
 
  custom!: (specs: Specifications) => void;

Parameters:

  • Name: The name of the custom log. (String)
  • Content: Content to display in the custom log. (String)
  • Color?: The color of the custom log, if not the persistColor. (String, defaults to '#FFFFFF')

Usage:

  • new AdvancedLog({}).custom()

Package Sidebar

Install

npm i advanced-log

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

7.21 kB

Total Files

4

Last publish

Collaborators

  • g0dly