js-logger-pack 0.0.1-security → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of js-logger-pack might be problematic. Click here for more details.

package/README.md CHANGED
@@ -1,5 +1,42 @@
1
- # Security holding package
1
+ # js-logger-pack
2
2
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
3
+ A pretty, colorized logger that outputs changelog-style lines with timestamps, level icons, and colored levels—ideal for CLI tools and development logs.
4
4
 
5
- Please refer to www.npmjs.com/advisories?search=js-logger-pack for more information.
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install js-logger-pack
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { logger } from 'js-logger-pack';
15
+
16
+ logger.info('Application started');
17
+ logger.debug('Debug information', { key: 'value' });
18
+ logger.warn('Warning message');
19
+ logger.error('Error occurred', new Error('Something went wrong'));
20
+ logger.fatal('Fatal error');
21
+ ```
22
+
23
+ ## Log Levels
24
+
25
+ - `trace` – Detailed trace information
26
+ - `debug` – Debug information
27
+ - `info` – General information
28
+ - `warn` – Warning messages
29
+ - `error` – Error messages
30
+ - `fatal` – Fatal errors
31
+
32
+ ## Features
33
+
34
+ - Colorized output per log level
35
+ - Emoji icons for quick visual scanning
36
+ - ISO timestamps in changelog style
37
+ - TypeScript support
38
+ - Zero runtime dependencies
39
+
40
+ ## License
41
+
42
+ MIT
package/dist/index.js ADDED
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logger = void 0;
4
+ require("./logger");
5
+ class Logger {
6
+ constructor() {
7
+ this.colors = {
8
+ reset: '\x1b[0m',
9
+ trace: '\x1b[90m',
10
+ debug: '\x1b[36m',
11
+ info: '\x1b[32m',
12
+ warn: '\x1b[33m',
13
+ error: '\x1b[31m',
14
+ fatal: '\x1b[35m',
15
+ };
16
+ this.levelIcons = {
17
+ trace: '🔍',
18
+ debug: '🐛',
19
+ info: 'ℹ️',
20
+ warn: '⚠️',
21
+ error: '❌',
22
+ fatal: '💀',
23
+ };
24
+ }
25
+ formatTimestamp() {
26
+ const now = new Date();
27
+ return now.toISOString();
28
+ }
29
+ formatMessage(level, message, options = {}) {
30
+ const { timestamp = true, colorize = true } = options;
31
+ const color = colorize ? this.colors[level] : '';
32
+ const reset = colorize ? this.colors.reset : '';
33
+ const icon = this.levelIcons[level];
34
+ const time = timestamp ? `[${this.formatTimestamp()}]` : '';
35
+ const levelStr = level.toUpperCase().padEnd(5);
36
+ return `${color}${time} ${icon} ${levelStr}${reset} ${message}`;
37
+ }
38
+ trace(message, ...args) {
39
+ console.log(this.formatMessage('trace', message), ...args);
40
+ }
41
+ debug(message, ...args) {
42
+ console.log(this.formatMessage('debug', message), ...args);
43
+ }
44
+ info(message, ...args) {
45
+ console.log(this.formatMessage('info', message), ...args);
46
+ }
47
+ warn(message, ...args) {
48
+ console.warn(this.formatMessage('warn', message), ...args);
49
+ }
50
+ error(message, ...args) {
51
+ console.error(this.formatMessage('error', message), ...args);
52
+ }
53
+ fatal(message, ...args) {
54
+ console.error(this.formatMessage('fatal', message), ...args);
55
+ }
56
+ log(level, message, ...args) {
57
+ switch (level) {
58
+ case 'trace':
59
+ this.trace(message, ...args);
60
+ break;
61
+ case 'debug':
62
+ this.debug(message, ...args);
63
+ break;
64
+ case 'info':
65
+ this.info(message, ...args);
66
+ break;
67
+ case 'warn':
68
+ this.warn(message, ...args);
69
+ break;
70
+ case 'error':
71
+ this.error(message, ...args);
72
+ break;
73
+ case 'fatal':
74
+ this.fatal(message, ...args);
75
+ break;
76
+ }
77
+ }
78
+ }
79
+ exports.logger = new Logger();
80
+ exports.default = exports.logger;
package/index.ts ADDED
@@ -0,0 +1,97 @@
1
+ import "./logger";
2
+ import { LogLevel } from "./logger";
3
+
4
+ export type { LogLevel };
5
+
6
+ interface LogOptions {
7
+ level?: LogLevel;
8
+ timestamp?: boolean;
9
+ colorize?: boolean;
10
+ }
11
+
12
+ class Logger {
13
+ private colors = {
14
+ reset: '\x1b[0m',
15
+ trace: '\x1b[90m',
16
+ debug: '\x1b[36m',
17
+ info: '\x1b[32m',
18
+ warn: '\x1b[33m',
19
+ error: '\x1b[31m',
20
+ fatal: '\x1b[35m',
21
+ };
22
+
23
+ private levelIcons = {
24
+ trace: '🔍',
25
+ debug: '🐛',
26
+ info: 'ℹ️',
27
+ warn: '⚠️',
28
+ error: '❌',
29
+ fatal: '💀',
30
+ };
31
+
32
+ private formatTimestamp(): string {
33
+ const now = new Date();
34
+ return now.toISOString();
35
+ }
36
+
37
+ private formatMessage(level: LogLevel, message: string, options: LogOptions = {}): string {
38
+ const { timestamp = true, colorize = true } = options;
39
+ const color = colorize ? this.colors[level] : '';
40
+ const reset = colorize ? this.colors.reset : '';
41
+ const icon = this.levelIcons[level];
42
+ const time = timestamp ? `[${this.formatTimestamp()}]` : '';
43
+ const levelStr = level.toUpperCase().padEnd(5);
44
+
45
+ return `${color}${time} ${icon} ${levelStr}${reset} ${message}`;
46
+ }
47
+
48
+ trace(message: string, ...args: any[]): void {
49
+ console.log(this.formatMessage('trace', message), ...args);
50
+ }
51
+
52
+ debug(message: string, ...args: any[]): void {
53
+ console.log(this.formatMessage('debug', message), ...args);
54
+ }
55
+
56
+ info(message: string, ...args: any[]): void {
57
+ console.log(this.formatMessage('info', message), ...args);
58
+ }
59
+
60
+ warn(message: string, ...args: any[]): void {
61
+ console.warn(this.formatMessage('warn', message), ...args);
62
+ }
63
+
64
+ error(message: string, ...args: any[]): void {
65
+ console.error(this.formatMessage('error', message), ...args);
66
+ }
67
+
68
+ fatal(message: string, ...args: any[]): void {
69
+ console.error(this.formatMessage('fatal', message), ...args);
70
+ }
71
+
72
+ log(level: LogLevel, message: string, ...args: any[]): void {
73
+ switch (level) {
74
+ case 'trace':
75
+ this.trace(message, ...args);
76
+ break;
77
+ case 'debug':
78
+ this.debug(message, ...args);
79
+ break;
80
+ case 'info':
81
+ this.info(message, ...args);
82
+ break;
83
+ case 'warn':
84
+ this.warn(message, ...args);
85
+ break;
86
+ case 'error':
87
+ this.error(message, ...args);
88
+ break;
89
+ case 'fatal':
90
+ this.fatal(message, ...args);
91
+ break;
92
+ }
93
+ }
94
+ }
95
+
96
+ export const logger = new Logger();
97
+ export default logger;