New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

log-talk

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

log-talk

Simple logger designed for browser and node. It logs with line number and color.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

log-talk

Simple logger designed for browser and terminal.

  • Line number where a bug occured (only for browser console now)
  • Timestamp when a bug occured
  • Highlight
  • Observe log message
  • Customizable

Usage

Use npm to install.

npm install --save log-talk
const LogTalk = require('log-talk');
const logger = new LogTalk();

// Default methods
logger.debug('This is debug');
logger.info('This is info', { message: 'Hello' });
logger.success('This is success');
logger.warn('This is warn');
logger.error('This is error', new Error('There is something wrong'));

// Define your own method
logger.setMethod({ name: 'foo', color: 'yellow', timeFormat: '[[]YYYY-MM-DD HH:mm:ss]' });
logger.foo('Foo');

// Override default methods
logger.setMethod({ name: 'info', color: 'red' });
logger.info('Now the label is red');

You can see this demo here on your browser.

Screenshot

screenshot

Log level

You can hide low level log such as debug.

const LogTalk = require('log-talk');
const minLevel = 3;
const logger = new LogTalk(minLevel);

Label

Set label option to customize label.
If you don't set label, name option is used as label.

const LogTalk = require('log-talk');
const logger = new LogTalk();
logger.setMethod({ name: 'foo', label: 'Foo' });

Time format

Set timeFormat option to customize time format.

const LogTalk = require('log-talk');
const logger = new LogTalk();
logger.setMethod({ name: 'foo', timeFormat: 'YYYY-MM-DD' });

It depends on Day.js to generate time string.
Formatting rules are here.

Highlight

Set color option to highlight.
NOTE: IE ignores color.

const LogTalk = require('log-talk');
const logger = new LogTalk();
logger.setMethod({ name: 'foo', color: 'yellow' });

These are defined colors.

  • default
  • blue
  • green
  • yellow
  • red

It's not flexible and few though.
I will improve it soon.

Default Methods

namelevelcolor
debug1default
info2blue
success3green
warn4yellow
error5red

Browser Support

  • IE@11
  • Edge
  • Firefox
  • Chrome
  • Safari

Keywords

client

FAQs

Package last updated on 29 Nov 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