Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moritzruth/log-groups
π± Log messages ... in groups
https://github.com/moritzruth/log-groups
console nodejs npm pretty
Last synced: about 2 months ago
JSON representation
π± Log messages ... in groups
- Host: GitHub
- URL: https://github.com/moritzruth/log-groups
- Owner: moritzruth
- License: mit
- Created: 2019-05-25T10:13:37.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-08T15:26:23.000Z (about 3 years ago)
- Last Synced: 2024-10-07T19:47:35.704Z (3 months ago)
- Topics: console, nodejs, npm, pretty
- Language: TypeScript
- Homepage:
- Size: 1.08 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Log Groups π±
> Log messages ... in groups## Install
Minimum required Node.js version is `v14.0.0`.![npm](https://img.shields.io/npm/v/log-groups?style=flat-square)
```sh
yarn add log-groups
# or
npm install log-groups
```## Usage
### Basic
```js
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
```js
const { LogGroup } = require("log-groups")// Every instance is also a Writable stream!
LogGroup().write("Woooow, streaming!")
```## Options
- title `string`
> The title of the group.
>
> Default `""`
- color [`typeof chalk.ForegroundColor`](https://github.com/chalk/chalk#colors)
> The color of the border and the title.
>
> Default `"blueBright"`
- box
> The style of the box.
> Can be any key from [this object](https://github.com/sindresorhus/cli-boxes/blob/ee5acd66ae7e676ac716a2f49884fbb5dc315e8d/boxes.json) or a custom object.
>
> Default `"round"`
- padding `{ top: number, right: number, bottom: number, left: number } | { topAndBottom: number, leftAndRight: number } | number`
> The padding inside the box.
>
> Default: `1`
- fallbackWidth `number`
> The box width which will be used if process.stdout.columns is null.
>
> Default: `50`
- maxWidth `number`
> The maximum width of the box.
>
> Default: `1000`