npm.io
5.0.0 • Published 6 months ago

@frankhoodbs/logging-utilities

Licence
ISC
Version
5.0.0
Deps
0
Size
13 kB
Vulns
0
Weekly
0

@frankhoodbs/logging-utilities

A collection of utilities for logging crafted with love by Frankhood Business Solutions s.r.l..

Version License

Features

  • Pre-defined Emoji icons for expressive logging.
  • Flexible and themed logging with colorful outputs.
  • Extensible with custom themes.

Installation

Using npm:

npm install @frankhoodbs/logging-utilities

Usage

Import the Utility
import {
    colorLog,
    progressBar,
    zzz,
    ok,
    brain,
} from '@frankhoodbs/logging-utilities';
Basic Logging
colorLog({
    icon: zzz,
    label: 'INFO',
    message: 'This is a basic log message',
});

Component Screenshot

Progress Logging
const percentageCount = (fractionValue / totalValue) * 100;
const percentage = isNaN(percentageCount) ? 0 : percentageCount;
//we divide by 3 to make the bar a bit less wide
const barProportion = 3;
const done = parseInt(percentage / barProportion, 10);
const missing = 100 / barProportion - done;
const emptyOrFull = percentage === 0 || percentage === 100;
const label = `My custom label -> ${percentage.toFixed(
    0
)}% (${fractionValue} / ${totalValue})`;
const isLabelBeforeBar = false;

progressBar({
    done,
    missing,
    emptyOrFull,
    label,
    isLabelBeforeBar,
});

Component Screenshot

Themed Logging
colorLog({
    icon: brain,
    label: 'DEBUG',
    message: 'Using the vue theme',
    themeName: 'vue',
});

colorLog({
    icon: ok,
    label: 'SUCCESS',
    message: 'Using a custom theme',
    theme: {
        backgroundColorLeft: '#FF0000',
        backgroundColorRight: '#00FF00',
        colorLeft: '#FFFFFF',
        colorRight: '#000000',
    },
});

Component Screenshot

Status Logging
colorLog({
    label: 'REJECTED',
    message: 'A task is rejected',
    status: -1,
});
colorLog({
    label: 'PENDING',
    message: 'A task is pending',
    status: 0,
});
colorLog({
    label: 'PASSED',
    message: 'A task is passed',
    status: 1,
});

Component Screenshot

Available Icons

For your convenience, the following pre-defined icons are available:

  • zzz:
  • bomb:
  • prohibited:
  • ok:
  • rightArrow:
  • info:
  • brain:
  • pop:
  • wait:
  • comet:
  • bell:

Certamente! Una delle maniere per farlo in un file README.md su GitHub è utilizzare badge colorati fatti con le righe di codice Markdown. Ecco un esempio di come potrebbe apparire:


Available Themes

The following themes are predefined and ready to use:

  • vue: #35494E #41B883
  • green: #41B883 #FFFFFF
  • orange: #5E3535 #ECA70A
  • purple: #a86cba #ddc9e4
  • purple2: #a86cba #ffffff
  • red: #9C7F3D #FF3311
  • red2: #5E3535 #FF3311
  • blue: #1F351E #1188FF
  • blue2: #1188FF #ffffff

Component Screenshot

However, you can also provide your own custom theme when logging.

License

This project is licensed under the ISC License.