Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@types/npmlog
Advanced tools
@types/npmlog provides TypeScript type definitions for the npmlog package, which is a logger with a log level and prefix system commonly used in Node.js applications.
Basic Logging
This feature allows you to log informational messages using the 'info' log level.
const log = require('npmlog');
log.info('info', 'This is an informational message');
Log Levels
This feature allows you to set different log levels such as 'verbose', 'info', 'warn', and 'error'.
const log = require('npmlog');
log.level = 'verbose';
log.verbose('verbose', 'This is a verbose message');
Custom Prefixes
This feature allows you to add custom log levels with specific prefixes and colors.
const log = require('npmlog');
log.addLevel('custom', 3000, { fg: 'blue' });
log.custom('custom', 'This is a custom log message');
Progress Bar
This feature allows you to display a progress bar in the log output.
const log = require('npmlog');
log.enableProgress();
log.showProgress();
log.progressEnabled = true;
log.progress('progress', 'Loading...');
Winston is a versatile logging library for Node.js with support for multiple transports, log levels, and formats. It is more feature-rich compared to npmlog and is suitable for more complex logging requirements.
Bunyan is a simple and fast JSON logging library for Node.js. It provides a structured logging approach and is well-suited for applications that require JSON log output.
Pino is a low-overhead, high-performance logging library for Node.js. It is designed to be extremely fast and efficient, making it a good choice for performance-critical applications.
npm install --save @types/npmlog
This package contains type definitions for npmlog (https://github.com/npm/npmlog#readme).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/npmlog.
/// <reference types="node" />
import { EventEmitter } from "events";
declare namespace npmlog {
// TODO: newStream, newGroup, setGaugeTemplate and setGaugeTemplateSet need to be added
interface Logger extends EventEmitter {
(): any;
level: string;
record: MessageObject[];
maxRecordSize: number;
prefixStyle: StyleObject;
headingStyle: StyleObject;
heading: string;
stream: any; // Defaults to process.stderr
log(level: LogLevels | string, prefix: string, message: string, ...args: any[]): void;
silly(prefix: string, message: string, ...args: any[]): void;
verbose(prefix: string, message: string, ...args: any[]): void;
info(prefix: string, message: string, ...args: any[]): void;
timing(prefix: string, message: string, ...args: any[]): void;
http(prefix: string, message: string, ...args: any[]): void;
notice(prefix: string, message: string, ...args: any[]): void;
warn(prefix: string, message: string, ...args: any[]): void;
error(prefix: string, message: string, ...args: any[]): void;
silent(prefix: string, message: string, ...args: any[]): void;
enableColor(): void;
disableColor(): void;
enableProgress(): void;
disableProgress(): void;
progressEnabled(): boolean;
enableUnicode(): void;
disableUnicode(): void;
pause(): void;
resume(): void;
addLevel(level: string, n: number, style?: StyleObject, disp?: string): void;
// Allows for custom log levels
// npmlog.addLevel("custom", level)
// npmlog.custom(prefix, message)
[key: string]: any;
}
type LogLevels = "silly" | "verbose" | "info" | "timing" | "http" | "notice" | "warn" | "error" | "silent";
interface StyleObject {
fg?: string | undefined;
bg?: string | undefined;
bold?: boolean | undefined;
inverse?: boolean | undefined;
underline?: boolean | undefined;
bell?: boolean | undefined;
}
interface MessageObject {
id: number;
level: string;
prefix: string;
message: string;
messageRaw: string;
}
}
declare var npmlog: npmlog.Logger;
export = npmlog;
These definitions were written by Daniel Schmidt, and Joseph Wynn.
FAQs
TypeScript definitions for npmlog
We found that @types/npmlog demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.