npm.io
4.0.5 • Published 3 weeks ago

@qui-cli/log

Licence
GPL-3.0
Version
4.0.5
Deps
3
Size
53 kB
Vulns
0
Weekly
0
Stars
1

@qui-cli/log

@qui-cli Plugin: Standardized winston wrapper

npm version Module type: ESM

Install

npm install @qui-cli/log @qui-cli/core

If developing a reusable plugin:

npm install --save-peer  @qui-cli/log@>=3.2

Usage

import { Log } from '@qui-cli/log';
import { Core } from '@qui-cli/core';

// process user-provided command-line arguments
const args = await Core.run();

// use Log
Log.debug(args);

Configuration

export type Configuration = Plugin.Configuration & {
  logFilePath?: string;
  stdoutLevel?: string;
  fileLevel?: string;
  levels?: CustomLevels;
  root?: string;
};
logFilePath

Optional path to log file (relative to root).

stdoutLevel

Log level to display via stdout/console, defaults to 'info';

fileLevel

Log level to write to log file (if logFilePath defined), defaults to 'all';

levels

Custom log levels to use, specified by Log.CustomLevels

root

Optional root to use as the base for relative logFilePath. If undefined, falls back to the path defined by @qui-cli/root.

Options

Exposes logFilePath, stdoutLevel, and fileLevel to user-provided command line arguments.

Initialization

Log will updating logging settings after user-provided command line arguments are parsed. If stdoutLevel is set to off, logging to the console will be disabled. If configure() has provided a logFilePath value previously and the user provides an additional logFilePath, logs will be written to both paths.

API

import { Log } from '@qui-cli/log';
Log.get(): winston.Logger

Get the actual winston logger object.

Log.log()

Directly invoke the winston log() method

Log.trace(), Log.debug(), Log.info(), Log.warning(), Log.error(), Log.fatal()

Log a string or object (to be stringified -- in color in the console) at the respective log level.