New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

awesome-logging

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awesome-logging

Advanced logging messages, interactive prompts, loading animations and more in TypeScript

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Awesome Logging

npm GitHub Workflow Status (branch) Azure DevOps tests Sonar Quality Gate

awesome-logging is a collection of fancy text outputs and inputs for CLI tools written in NodeJS. No matter what you want to log to the terminal or what information you need from the user, awesome-logging will help you do so.

  • You want to show the progress of a certain task while also logging messages to the terminal while keeping everythign nice and formatted? No problem.
  • You want the user to select one or multiple options of a given list? No problem!
  • You want to log messages in the background while showing a fancy animation or a prompt to the user? No problem!

Key functionality

  • Written in TypeScript (Strongly typed)
  • Live-update logging messages in a reliable way
  • Multi-line logging
  • Loading animations and progress bars
  • Interactive prompts to get user input
  • Interrupt currently playing animations with regular log entries
  • Extendable design (add your own loggers / prompts)

multiline example

Installation

yarn add awesome-logging
// or
npm i awesome-logging

Examples

import { AwesomeLogger } from 'awesome-logger';
// Example: Simple text logging
AwesomeLogger.log('Welcome to awesome-logging!');
const logControl = AwesomeLogger.log('Is this a logging library?');
setTimeout(() => logControl.setText('This is an awesome-logging library!'), 1500);
setTimeout(() => logControl.setText('Cool!'), 3000);

simple text logging

// Example: Simple text logging (with line breaks)
const textA = 'One line of text...';
const textB = 'Multiple\nLines\nof Text!';
let state = true;
const logControl = AwesomeLogger.log(textA);
setInterval(() => {
  state = !state;
  logControl.setText(state ? textA : textB);
}, 1000);

text linebreak logging

// Example: Progress Bar
const logProgressControl = AwesomeLogger.log('progress', {
  totalProgress: 100,
  text: 'Very important progress:'
});

let i = 0;
const interval = setInterval(() => {
  logProgressControl.setProgress(i++);
  if (i === 100) {
    clearInterval(interval);
  }
}, 500);

progress logging

AwesomeLogger Methods

AwesomeLogger.create(loggerType, loggerOptions): LoggerControl

AwesomeLogger.log(text): LoggerControl
AwesomeLogger.log(logger): LoggerControl
AwesomeLogger.log(loggerType, loggerOptions): LoggerControl

AwesomeLogger.prompt(promptType, promptOptions): PromptControl
AwesomeLogger.interrupt(text): void

Logger types

Text

The simplest of all loggers; logs any printable string, no matter if one, or multiple lines.

LoggerOptions

Optiontypedescriptiondefault
textstringThe text that should be logged.''

LoggerControl

MethodreturnTypedescription
setText(text: string)voidSets a new text to the logger.

Spinner

Logs a loading spinner with a custom loading animation and text.

LoggerOptions

Optiontypedescriptiondefault
textstringThe description text of the loading spinner.''
spinnerFramesstring[]The array of strings that are used for the animation.['. ', '.. ', '...', '.. ']
spinnerDelaynumberThe amount of ms between each spinnerframe.500

LoggerControl

MethodreturnTypedescription
stop(options: { succeeded?: boolean; removeLine?: boolean; text?: string })voidStops the spinner and changes the logging accordingly to the provided options.

Progress

Loggs a progressbar with optional text.

LoggerOptions

Optiontypedescriptiondefault
totalProgressnumberThe maximum number the progress can reach.100
textstringThe text that is displayed in front of the bar.''
completedTextstringThe text that is displayed when the progress reaches 100%.''
unfilledCharstringThe character that is pronted for the uncompleted section of the bar.'·'
filledCharstringThe character that is pronted for the completed section of the bar.'■'
borderCharstringThe caharter that is printed on the left and right of the bar.'■'
maxWidthnumberThe maximum cound characters the progressbar can have can.Terminal Width
borderColorAwesomeLoggerColorThe color of the border chars.'GRAY'
unfilledColorAwesomeLoggerColorThe color of the uncompleted part of the bar.'GRAY'
filledColorAwesomeLoggerColorThe color of the completed part of the bar.'WHITE'

Note: For performance reasons do not specify the colors of unfilled or filled characters directly in the string option, but by the dedicated color option.

LoggerControl

MethodreturnTypedescription
setProgress(progress: number, text?: string)voidSets the current progress and optionally a new text.

Checklist

Logs a list of items that have a certain state like 'pending', 'inProgress', 'succeeded' and more.

LoggerOptions

Optiontypedescriptiondefault
itemsAwesomeChecklistLoggerItemAll items that are part of the checklist.[]

LoggerControl

MethodreturnTypedescription
changeState(index: number, state: AwesomeChecklistLoggerState, newText?: string)voidChanges the state of one item based on the index. Optionally sets a new text for that item.

Multi

Combines multiple loggers that were created previously and loggs them below each other.

LoggerOptions

Optiontypedescriptiondefault
childrenAwesomeLoggerBase[]The array of loggers that were created previously.[]

LoggerControl

MethodreturnTypedescription
getChild<T extends AwesomeLoggerBase>(index: number)TReturns the child at the given index. Be cautious as you have to be sure what kind of logger is present at the provided index.

Keywords

FAQs

Package last updated on 27 Jul 2021

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