New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

logua

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logua

Logging utility for node.

latest
Source
npmnpm
Version
3.0.3
Version published
Maintainers
1
Created
Source

logua

logua

Logging utility for node and the browser. Displays colored package namespace in front and exits on error. Unless message ends in ".!?\n" a dot will be added to the end.

import { create } from 'logua'

// First create the log with the package context.
const log = create('my-pkg', 'blue')

log(`Found ${files} files`)

// => my-pkg Found 5 files.

log('Please add a description field', 'warning')

// => my-pkg Please add a description field.

log('package.json file is missing', 'error')

// => my-pkg package.json file is missing.
// => exits the process!

The following colors are available: black, red, green, yellow, blue, magenta, cyan, white, gray, grey, redBright, greenBright, yellowBright, blueBright, magentaBright, cyanBright, whiteBright, darkOrange, orange

Separate file

// log.js

import { create } from 'logua'

export const log = create('some-pkg', 'red')

Then import the contextualized log:

import { log } from './log.js'

log('Hello World')

// => some-pkg Hello World.

Grouping messages

To avoid spamming the log messages can be grouped. After a timeout a single message will be output instead of various messages.

const files = ['hello.js', 'world.js', 'more-files.js']

files.forEach((file) =>
  log(`Copying ${file}`, {
    // Some identifier for the group.
    group: 'copy',
    // Group message, used if there is more than one log for this id during the timeout.
    groupMessage: (count: number) => `Copying ${count} files`,
    groupMessage: 'Files copied successfully',
    // Optional timeout until messages are collected.
    timeout: 100,
  }),
)

// => Copying 3 files.

Further Options

By default a newline will be added after each message. This can be changed globally or for each single log.

const log = create('my-pkg', 'blue', false) // newLine = false

log('Hello World', { newLine: true }) // Force newLine for this message.

Keywords

log

FAQs

Package last updated on 08 Dec 2023

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