🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@evokegroup/console-logger

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evokegroup/console-logger

Logs timestamped messages to the console.

latest
npmnpm
Version
1.0.3
Version published
Maintainers
3
Created
Source

@evokegroup/console-logger

Logs timestamped messages to the console.

Class: ConsoleLogger

const ConsoleLogger = require('@evokegroup/console-logger');
ConsoleLogger.log('Log this message');
// Expected result: [HH:mm:ss] Log this message

Static Properties

ConsoleLogger.Style

NameDescription
BackgroundBackground colors
Background.Black
Background.Blue
Background.Cyan
Background.Gray
Background.Green
Background.Magenta
Background.Red
Background.White
Background.Yellow
Background.BrightBlue
Background.BrightCyan
Background.BrightGreen
Background.BrightMagenta
Background.BrightRed
Background.BrightWhite
Background.BrightYellow
ForegroundForeground colors
Foreground.Black
Foreground.Blue
Foreground.Cyan
Foreground.Gray
Foreground.Green
Foreground.Magenta
Foreground.Red
Foreground.White
Foreground.Yellow
Foreground.BrightBlue
Foreground.BrightCyan
Foreground.BrightGreen
Foreground.BrightMagenta
Foreground.BrightRed
Foreground.BrightWhite
Foreground.BrightYellow
InverseInverse of default style
ResetResets to default style
UnderscoreUnderscores the text

Static Methods

ConsoleLogger.setStylesEnabled(flag)

Enable or disabled styles globally.

ConsoleLogger.setTimestampEnabled(flag)

Enable or disabled timestamps globally.

ConsoleLogger.setTimestampStyle(styles)

Set timestamp style globally.

ConsoleLogger.log(message, styles, timestamp = true)

Logs a message with given styles.

const ConsoleLogger = require('@evokegroup/console-logger');
ConsoleLogger.log('Log this message');
ConsoleLogger.log('Another message in blue', ConsoleLogger.Style.Foreground.Blue);
ConsoleLogger.log('Underscored in green with no timestamp', [ConsoleLogger.Style.Foreground.Green, ConsoleLogger.Style.Underscore], false);
ConsoleLogger.log([
  new ConsoleLogger.MessagePart('red', ConsoleLogger.Style.Foreground.Red),
  new ConsoleLogger.MessagePart(' green', ConsoleLogger.Style.Foreground.Green)
]);

Parameters

NameTypeDefaultDescription
messageArray<ConsoleLogger.MessagePart>, ConsoleLogger.MessagePart, stringThe message to be logged
stylesArray<ConsoleLogger.Style>, ConsoleLogger.StyleThe style of the message
timestampbooleantruePrint a timestamp

ConsoleLogger.error(message, timestamp = true)

Logs a message in red.

const ConsoleLogger = require('@evokegroup/console-logger');
ConsoleLogger.error('error');

ConsoleLogger.info(message, timestamp = true)

Logs a message in cyan.

const ConsoleLogger = require('@evokegroup/console-logger');
ConsoleLogger.info('info');

ConsoleLogger.warn(message, timestamp = true)

Logs a message in yellow.

const ConsoleLogger = require('@evokegroup/console-logger');
ConsoleLogger.warn('warn');

Class: ConsoleLogger.MessagePart

constructor(text, styles)

ConsoleLogger.log([
  new ConsoleLogger.MessagePart('red', ConsoleLogger.Style.Foreground.Red),
  new ConsoleLogger.MessagePart(' green', ConsoleLogger.Style.Foreground.Green)
]);

Properties

NameTypeDescription
textstringThe text to log
stylesArray<ConsoleLogger.Style>, ConsoleLogger.StyleThe style to apply to the text

FAQs

Package last updated on 14 Jan 2022

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