Gathering detailed insights and metrics for @medishn/logger
Gathering detailed insights and metrics for @medishn/logger
Gathering detailed insights and metrics for @medishn/logger
Gathering detailed insights and metrics for @medishn/logger
npm install @medishn/logger
Typescript
Module System
Node Version
NPM Version
72
Supply Chain
97.4
Quality
81.3
Maintenance
100
Vulnerability
100
License
TypeScript (93.78%)
Shell (6.22%)
Total Downloads
147
Last Day
2
Last Week
77
Last Month
147
Last Year
147
73 Commits
2 Branches
2 Contributors
Minified
Minified + Gzipped
Latest Version
2.0.0
Package Id
@medishn/logger@2.0.0
Unpacked Size
27.77 kB
Size
7.60 kB
File Count
29
NPM Version
10.9.1
Node Version
22.3.0
Publised On
15 Dec 2024
Cumulative downloads
Total Downloads
Last day
100%
2
Compared to previous day
Last week
10%
77
Compared to previous week
Last month
0%
147
Compared to previous month
Last year
0%
147
Compared to previous year
3
A customizable and modular logger designed for both console and file-based logging with support for file rotation, buffering, color personalization, and modular transport handling.
info
, warn
, error
, debug
) or set your own.info
if not specified.1npm install @medishn/logger
1import { Logger } from '@medishn/logger'; 2 3const logger = new Logger({ 4 transports: ['console', 'file'], 5 file: 'app.log', 6}); 7 8logger.log({ 9 message: 'Application started', 10 level: 'info', 11 category: 'APP', 12});
You can personalize console log colors for each log level.
1const logger = new Logger({ 2 transports: ['console'], 3 console: { 4 colors: { 5 info: '\x1b[32m', // green 6 warn: '\x1b[33m', // yellow 7 error: '\x1b[31m', // red 8 debug: '\x1b[34m', // blue 9 }, 10 }, 11}); 12 13logger.log({ message: 'Server started', level: 'info' });
You can specify file rotation settings, such as maximum file size, and buffer log entries to be flushed at regular intervals.
1const logger = new Logger({ 2 transports: ['file'], 3 file: 'app.log', 4 rotation: { maxSize: 1024 * 1024 }, // 1MB file size before rotating 5}); 6 7logger.log({ message: 'Logging to file with rotation', level: 'debug' });
opts: Options
transports: Array<"console" | "file">
: Specifies where to log (console, file, or both).file?: string
: The path for the log file.format?: "iso" | "locale"
: Log date format (default is "iso"
).rotation?: { maxSize: number }
: File rotation settings.console?: { colors: Record<LogLevel, string> }
: Custom console log colors.log(args: Arguments.Log)
: Log a message.close()
: Closes the file transport and flushes any remaining logs.This project is licensed under the MIT License.
No vulnerabilities found.
No security vulnerabilities found.