1.1.0 • Published 2 years ago

cology v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Cology


npm node.js build npm GitHub issues GitHub stars GitHub license

Highlights

  • Bring order to your console log.

  • Very simple API

  • Supports TypeScript

Install

$ npm install cology

Usage

const { Cology } = require('cology');
/*TS
import { Cology } from 'cology'
*/

Cology.log('info', 'Info Message');
//> Info Message

Cology.log('error', 'Error Message');
//[ERROR] Error Message

Cology.setBorder('--------');
Cology.log('warn', 'Title:\nWarn Message');
/*
--------
[WARN] Title:
[WARN] Warn Message
--------
	
*/

API

It's easy to use Cology APIs to log.

Cology.log(level, message)

Example: Cology.log('debug', 'Debug Message')

Output a message to the console. The decoration changes depending on the level you specify.

There are the following types of levels.

levelDescription
'debug'No particular decoration
'info'It will be prefixed with ">"
'success'Same as info, but it will be green
'warn'It will be prefixed with "WARN" and the color will turn yellow
'error'It will be prefixed with "ERROR" and the color will turn red
'fatal'It will be prefixed with "FATAL_ERROR" and the color will turn bold red

Cology.date()

Example: Cology.date()

Displays the time in the format YYYY-MM-DDTHH:mm:ss.

Cology.setBorder(border)

Example: Cology.setBorder('--------')

Enclose messages in a specified border when logging. The default value is ''. If '', no new line is created.

Cology.push() & Cology.pop()

Example:

Cology.push();

Cology.setBorder('<><><><>');
Cology.log('info', 'Info Message');

Cology.pop();

These two methods are used as a set.

The border between push and pop will be temporary. Temporary boarder does not work on the outside.

A border set anywhere other than between push and pop will function as a global border throughout the code.

Author

LICENSE

This project is licensed under the MIT License - see the LICENSE file for details.