Socket
Socket
Sign inDemoInstall

cli-multitask-log

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cli-multitask-log

refresh log in situ for multi tasks


Version published
Weekly downloads
1
Maintainers
1
Install size
30.8 kB
Created
Weekly downloads
 

Readme

Source

node-cli-multitask-log

refresh log in situ for multi tasks

Usage

const taskLog = require('cli-multitask-log');

//'tasks' is just a Map object, it saves the log content for the tasks
//so you can set any key that can be a key for a Map object
taskLog.tasks.set('task1','log content here');//'task1' is just a key, it won't be displayed
taskLog.tasks.set('task2',()=>'random:'+Math.random());//set function as the value for generating log content before refresh
//IMPORTANT: order of the tasks is the same as the order of the keys in the Map object


//to delete a task
taskLog.tasks.delete('task1');
//to clear all tasks
taskLog.tasks.clear();


//manual refresh
taskLog.refreshLogs();
//NOTICE: This method will not output anything in none TTY environments
//to force output the last result, use
taskLog.refreshLogs(true);


//or start an auto refresh task
taskLog.autoRefreshStart(1000);//set auto refresh interval to 1000ms
//then stop it when you want
taskLog.autoRefreshStop();
//it will clear tasks by default, if you want to keep tasks,use
taskLog.autoRefreshStop(false);


//normally you shoud not log other things when logging task logs
//but if you do, you must call breakLog() after your log to prevent it from being overwritten
taskLog.breakLog();

Here are all the usages above, just a simple log tool.

This lib also contaions a simple progress bar:

taskLog.tasks.set('any name',
	taskLog.simpleProgress('>', () => [process.uptime() * 1000, 100000])
);

Keywords

FAQs

Last updated on 21 Dec 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc