@qui-cli/log
v4.0.1
Published
@qui-cli Plugin: Standardized winston wrapper
Readme
@qui-cli/log
@qui-cli Plugin: Standardized winston wrapper
Install
npm install @qui-cli/log @qui-cli/coreUsage
import { Log } from '@qui-cli/log';
import { Core } from '@qui-cli/core';
// process user-provided command-line arguments
const args = Core.init();
// 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.
