3.0.0 • Published 5 years ago
log-groups v3.0.0
Log Groups 🍱
Log messages ... in groups
Install
Minimum required Node.js version is v14.0.0.
yarn add log-groups
# or
npm install log-groupsUsage
Basic
const { LogGroup } = require("log-groups")
// You don’t have to provide any options at all. Default values will apply.
const mainProcess = new LogGroup()
const process1 = new LogGroup({
// All available options:
title: "Process 1",
color: "green",
padding: 0,
box: "classic",
fallbackWidth: 20,
maxWidth: 50
})
// No new block will be created, instead,
// the second message will be appended to the last block.
mainProcess.log("Log 1")
mainProcess.log("Log 2")
// A new block will be created.
process1.log("Process 1 started")
mainProcess.log("Main process again")
process1.log("Aaaand, it‘s me again.")Streaming
const { LogGroup } = require("log-groups")
// Every instance is also a Writable stream!
LogGroup().write("Woooow, streaming!")Options
- title
stringThe title of the group.
Default
"" - color
typeof chalk.ForegroundColorThe color of the border and the title.
Default
"blueBright" - box
The style of the box. Can be any key from this object or a custom object.
Default
"round" - padding
{ top: number, right: number, bottom: number, left: number } | { topAndBottom: number, leftAndRight: number } | numberThe padding inside the box.
Default:
1 - fallbackWidth
numberThe box width which will be used if process.stdout.columns is null.
Default:
50 - maxWidth
numberThe maximum width of the box.
Default:
1000