Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

conslog

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conslog

Console Logging, done the right way.

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ConsLog

The console, rewritten from scratch.

Usage

To install,

npm install conslog

or

yarn add conslog

After that, there are three ways to use ConsLog. The first way is to replace the console object.

delete console;
const console = require('conslog');

The second, semi-safe way is to move the console object.

const v8 = require('v8');
const clone = obj => {
  return v8.deserialize(v8.serialize(obj));
};
const oldConsole = clone(console) // Or however you want to deepclone.
delete console;
const console = require('conslog')

The third, safer way, is to include it as a separate package.

const cons = require('conslog');

Functions

  • console is ConsLog, oldC is the original console.

log

function log(msg: any, ...optionalParams?: any[]);

Logs to stdout. Works exactly like oldC.log except for the indentation.

warn

function warn(msg: any, head?: string, ...optionalParams?: any[]);

Logs to stdout as a warning. Prefixed with 'warn' or head.

info

function info(msg: any, head?: string, ...optionalParams?: any[]);

Logs to stdout as an information. Prefixed with 'info' or head.

error

function error(e: Error, head?: string, ...optionalParams?: any[]);

Logs to stdout as an error. Doesn't throw. Prefixed with 'err' or head.

success

function success(msg: any, head?: string, ...optionalParams?: any[]);

Logs to stdout as a success message. Prefixed with 'succ' or head.

fatal

function fatal(e: Error, head?: string, ...optionalParams?: any[]);

Logs to stdout as a fatal error. Throws. Prefixed with 'fatal' or head.

changeTheme

interface Theme {
  i: string[], // Info color, defaults to ["blue"]
  hi: string[],// Info prefix color, defaults to ["bgBlue", "white"]
  w: string[], // Warn color, defaults to ["yellow"]
  hw: string[],// Warn prefix color, defaults to ["bgYellow", "white"]
  e: string[], // Error color, defaults to ["red"]
  he: string[],// Error prefix color, defaults to ["bgRed", "white"]
  f: string[], // Fatal color, defaults to ["magenta"]
  hf: string[],// Fatal prefix color, defaults to ["bgMagenta", "white"]
  s: string[], // Success color, defaults to ["green"]
  hs: string[],// Success prefix color, defaults to ["bgGreen", "white"]
  c: string[], // Catched error color, defaults to ["red"]
  hc: string[],// Catched error prefix color, defaults to ["bgGreen", "white"]
  g: string[]  // Group header color, defaults to ["inverse"]
}

function changeTheme(theme: Theme);

Sets the color theme. See the colors doc for information on how to write a theme.

Variables

indentationSteps

let indentationSteps: number = 1;

How many spaces to indent each time.

maxIndent

let maxIndent: number = 10;

The maximum indentation you can reach. Set to -1 for no limit.

msg

interface Messages {
  info: string,
  warn: string,
  error: string,
  fatal: string,
  catched: string,
  success: string,
  groupIn: string,
  groupOut: string
}

let msg: Messages = {
  info: " INFO ",
  warn: " WARN ",
  error: "  ERR ",
  fatal: "FATAL ",
  catched: "CATCH ",
  success: " SUCC ",
  groupIn: "> ",
  groupOut: "< "
}

The prefixes applied to the specific logging functions.

License

MIT

Keywords

FAQs

Package last updated on 11 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc