1.2.2 • Published 3 years ago

@lauwri/log v1.2.2

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

log

Sponsored

A lightweight node logger with zero dependencies.

Installation

Install through npm

npm i @lauwri/log
yarn add @lauwri/log

Usage

import log from "@lauwri/log";

// Enables logging to file, use outputFile to change output
log.setup({
  enableFile: true,
});

log.info("This is a regular log");
//INFO: 2022-05-16T22:53:47.688Z example.ts:8:5: This is a regular log

log.warn("This is a warning log");
//WARN: 2022-05-16T22:53:47.692Z example.ts:9:5: This is a warning log

log.error("This is a error log");
//ERROR: 2022-05-16T22:53:47.693Z example.ts:10:5: This is a error log

log.debug("This is a debug log");
//DEBUG: 2022-05-16T22:53:47.694Z example.ts:11:5: This is a debug log

API

import log from "@lauwri/log";

info warn error debug (message?: any, ...args: any[]):
Log by level

setup(options):
Set global options for logger

options:

commanddescriptiondefault
logLevelsArray of levels to logInfo,Debug,Warn,Error
enableLoggingEnable logging to consoletrue
enableFileEnable logging to filefalse
outputFilePath to log output file./logs/logs.txt
tagDateTags file with a timestamptrue
tagLevelTags file with a log leveltrue
tagColorTags file with a colortrue
tagFileMessageTags file with a messageLogging started at n from origin x
colorColors for logging levels

Colors:
ANSI colorcodes. If any color is present, log adds Reset as last argument to console.

NameValue
Reset"\x1b[0m"
Bright"\x1b[1m"
Dim"\x1b[2m"
Underscore"\x1b[4m"
Blink"\x1b[5m"
Reverse"\x1b[7m"
Hidden"\x1b[8m"
FgBlack"\x1b[30m"
FgRed"\x1b[31m"
FgGreen"\x1b[32m"
FgYellow"\x1b[33m"
FgBlue"\x1b[34m"
FgMagenta"\x1b[35m"
FgCyan"\x1b[36m"
FgWhite"\x1b[37m"
BgBlack"\x1b[40m"
BgRed"\x1b[41m"
BgGreen"\x1b[42m"
BgYellow"\x1b[43m"
BgBlue"\x1b[44m"
BgMagenta"\x1b[45m"
BgCyan"\x1b[46m"
BgWhite"\x1b[47m"
1.2.0

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.0

4 years ago

1.0.0

4 years ago