@i14a/logger 1.0.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 i14a-dsc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # FancyLogger
2
+
3
+ Simple console logger that prints boxed, colored messages.
4
+
5
+ Usage:
6
+
7
+ Install:
8
+
9
+ ```bash
10
+ npm install @i14a/logger
11
+ ```
12
+
13
+ Import:
14
+
15
+ ```ts
16
+ import FancyLogger from '@i14a/logger';
17
+
18
+ FancyLogger.success('Done');
19
+ ```
@@ -0,0 +1,4 @@
1
+ import { FancyLogger } from './logger';
2
+ export { FancyLogger };
3
+ export type { FancyLoggerOptions } from './types';
4
+ export default FancyLogger;
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FancyLogger = void 0;
4
+ const logger_1 = require("./logger");
5
+ Object.defineProperty(exports, "FancyLogger", { enumerable: true, get: function () { return logger_1.FancyLogger; } });
6
+ exports.default = logger_1.FancyLogger;
@@ -0,0 +1,68 @@
1
+ import type { FancyLoggerOptions } from './types';
2
+ export declare class FancyLogger {
3
+ /**
4
+ * Log with green color box.
5
+ * @param message Message string or array
6
+ * @param title The title of message
7
+ * @example
8
+ * FancyLogger.success('Success!');
9
+ */
10
+ static success(message: string | string[], options?: FancyLoggerOptions): void;
11
+ /**
12
+ * Log with blue color box.
13
+ *
14
+ * @param message Message string or array
15
+ * @param title The title of message
16
+ * @example
17
+ * FancyLogger.info('An info message');
18
+ */
19
+ static info(message: string | string[], options?: FancyLoggerOptions): void;
20
+ /**
21
+ * Log with yellow color box.
22
+ *
23
+ * @param message Message string or array
24
+ * @param title The title of message
25
+ * @example
26
+ * FancyLogger.warning('Be careful!');
27
+ */
28
+ static warning(message: string | string[], options?: FancyLoggerOptions): void;
29
+ /**
30
+ * @deprecated This method is deprecated. Use `FancyLogger.warning` instead.
31
+ */
32
+ static warn(message: string | string[], options?: FancyLoggerOptions): void;
33
+ /**
34
+ * Log with red color box.
35
+ *
36
+ * @param message Message string or array
37
+ * @param title The title of message
38
+ * @example
39
+ * FancyLogger.error(['An error has occurred');
40
+ */
41
+ static error(message: string | string[], options?: FancyLoggerOptions): void;
42
+ /**
43
+ * Log with rainbow colors
44
+ * @param message Message string or array
45
+ * @param title The title of message
46
+ * @example
47
+ * FancyLogger.rainbow('Rainbow');
48
+ */
49
+ static rainbow(message: string | string[], options?: FancyLoggerOptions): void;
50
+ /**
51
+ * with a sparkle effect.
52
+ *
53
+ * @param message Message string or array
54
+ * @param title The title of message
55
+ * @example
56
+ * FancyLogger.sparkle('Sparkle!');
57
+ */
58
+ static sparkle(message: string | string[], options?: FancyLoggerOptions): void;
59
+ /**
60
+ * The log is output as a loading message in a box.
61
+ * @param message Message to be output
62
+ * @param title Title to be output (optional)
63
+ * @example
64
+ * FancyLogger.loading('Loading...');
65
+ * FancyLogger.loading('Please wait...', '🔥 LOADING');
66
+ */
67
+ static loading(message: string, title?: string): void;
68
+ }
package/dist/logger.js ADDED
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FancyLogger = void 0;
7
+ const boxen_1 = __importDefault(require("boxen"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ class FancyLogger {
10
+ /**
11
+ * Log with green color box.
12
+ * @param message Message string or array
13
+ * @param title The title of message
14
+ * @example
15
+ * FancyLogger.success('Success!');
16
+ */
17
+ static success(message, options) {
18
+ const { title } = options ?? {};
19
+ const boxedMessage = (0, boxen_1.default)(chalk_1.default.green.bold(message), {
20
+ padding: 1,
21
+ margin: 1,
22
+ borderStyle: 'round',
23
+ borderColor: 'green',
24
+ backgroundColor: '#1a1a1a',
25
+ title: title ?? chalk_1.default.green.bold('✅ SUCCESS'),
26
+ titleAlignment: 'center',
27
+ });
28
+ console.log(boxedMessage);
29
+ }
30
+ /**
31
+ * Log with blue color box.
32
+ *
33
+ * @param message Message string or array
34
+ * @param title The title of message
35
+ * @example
36
+ * FancyLogger.info('An info message');
37
+ */
38
+ static info(message, options) {
39
+ const { title } = options ?? {};
40
+ const boxedMessage = (0, boxen_1.default)(chalk_1.default.blue.bold(message), {
41
+ padding: 1,
42
+ margin: 1,
43
+ borderStyle: 'round',
44
+ borderColor: 'blue',
45
+ backgroundColor: '#1a1a1a',
46
+ title: title ?? chalk_1.default.blue.bold('ℹ️ INFO'),
47
+ titleAlignment: 'center',
48
+ });
49
+ console.log(boxedMessage);
50
+ }
51
+ /**
52
+ * Log with yellow color box.
53
+ *
54
+ * @param message Message string or array
55
+ * @param title The title of message
56
+ * @example
57
+ * FancyLogger.warning('Be careful!');
58
+ */
59
+ static warning(message, options) {
60
+ const { title } = options ?? {};
61
+ const boxedMessage = (0, boxen_1.default)(chalk_1.default.yellow.bold(message), {
62
+ padding: 1,
63
+ margin: 1,
64
+ borderStyle: 'round',
65
+ borderColor: 'yellow',
66
+ backgroundColor: '#1a1a1a',
67
+ title: title ?? chalk_1.default.yellow.bold('⚠️ WARNING'),
68
+ titleAlignment: 'center',
69
+ });
70
+ console.log(boxedMessage);
71
+ }
72
+ /**
73
+ * @deprecated This method is deprecated. Use `FancyLogger.warning` instead.
74
+ */
75
+ static warn(message, options) {
76
+ this.warning(message, options);
77
+ }
78
+ /**
79
+ * Log with red color box.
80
+ *
81
+ * @param message Message string or array
82
+ * @param title The title of message
83
+ * @example
84
+ * FancyLogger.error(['An error has occurred');
85
+ */
86
+ static error(message, options) {
87
+ const { title } = options ?? {};
88
+ const boxedMessage = (0, boxen_1.default)(chalk_1.default.red.bold(message), {
89
+ padding: 1,
90
+ margin: 1,
91
+ borderStyle: 'round',
92
+ borderColor: 'red',
93
+ backgroundColor: '#1a1a1a',
94
+ title: title ?? chalk_1.default.red.bold('❌ ERROR'),
95
+ titleAlignment: 'center',
96
+ });
97
+ console.log(boxedMessage);
98
+ }
99
+ /**
100
+ * Log with rainbow colors
101
+ * @param message Message string or array
102
+ * @param title The title of message
103
+ * @example
104
+ * FancyLogger.rainbow('Rainbow');
105
+ */
106
+ static rainbow(message, options) {
107
+ const { title } = options ?? {};
108
+ if (Array.isArray(message)) {
109
+ message = message.join('\n');
110
+ }
111
+ const rainbowColors = [chalk_1.default.red, chalk_1.default.yellow, chalk_1.default.green, chalk_1.default.cyan, chalk_1.default.blue, chalk_1.default.magenta];
112
+ let rainbowContent;
113
+ if (rainbowColors.length === 0) {
114
+ rainbowContent = message;
115
+ }
116
+ else {
117
+ rainbowContent = message
118
+ .split('')
119
+ .map((char, index) => {
120
+ const colorFn = rainbowColors[index % rainbowColors.length];
121
+ return colorFn ? colorFn(char) : char;
122
+ })
123
+ .join('');
124
+ }
125
+ const boxedMessage = (0, boxen_1.default)(rainbowContent, {
126
+ padding: 1,
127
+ margin: 1,
128
+ borderStyle: 'double',
129
+ borderColor: 'magenta',
130
+ backgroundColor: '#1a1a1a',
131
+ title: title ?? chalk_1.default.magenta.bold('🌈 RAINBOW'),
132
+ titleAlignment: 'center',
133
+ });
134
+ console.log(boxedMessage);
135
+ }
136
+ /**
137
+ * with a sparkle effect.
138
+ *
139
+ * @param message Message string or array
140
+ * @param title The title of message
141
+ * @example
142
+ * FancyLogger.sparkle('Sparkle!');
143
+ */
144
+ static sparkle(message, options) {
145
+ const { title } = options ?? {};
146
+ const sparkleContent = `✨ ${message} ✨`;
147
+ const boxedMessage = (0, boxen_1.default)(chalk_1.default.cyan.bold(sparkleContent), {
148
+ padding: 1,
149
+ margin: 1,
150
+ borderStyle: 'round',
151
+ borderColor: 'cyan',
152
+ backgroundColor: '#1a1a1a',
153
+ title: title ?? chalk_1.default.cyan.bold('⭐ SPARKLE'),
154
+ titleAlignment: 'center',
155
+ });
156
+ console.log(boxedMessage);
157
+ }
158
+ /**
159
+ * The log is output as a loading message in a box.
160
+ * @param message Message to be output
161
+ * @param title Title to be output (optional)
162
+ * @example
163
+ * FancyLogger.loading('Loading...');
164
+ * FancyLogger.loading('Please wait...', '🔥 LOADING');
165
+ */
166
+ static loading(message, title) {
167
+ const content = chalk_1.default.yellow.bold(`⏳ ${message}...`);
168
+ const boxedMessage = (0, boxen_1.default)(content, {
169
+ padding: 1,
170
+ margin: 1,
171
+ borderStyle: 'round',
172
+ borderColor: 'yellow',
173
+ backgroundColor: '#1a1a1a',
174
+ title: title ?? chalk_1.default.yellow.bold('🔄 LOADING'),
175
+ titleAlignment: 'center',
176
+ });
177
+ console.log(boxedMessage);
178
+ }
179
+ }
180
+ exports.FancyLogger = FancyLogger;
@@ -0,0 +1,3 @@
1
+ export interface FancyLoggerOptions {
2
+ title?: string;
3
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@i14a/logger",
3
+ "version": "1.0.0",
4
+ "description": "Fancy logger for my projects",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "publishConfig": {
11
+ "access": "public",
12
+ "registry": "https://registry.npmjs.org/"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "prepare": "npm run build",
17
+ "test": "echo \"Error: no test specified\" && exit 1"
18
+ },
19
+ "keywords": [
20
+ "database",
21
+ "json",
22
+ "key-value",
23
+ "storage"
24
+ ],
25
+ "author": "i14a <dev.i14a.dsc@gmail.com>",
26
+ "license": "UNLICENSED",
27
+ "dependencies": {
28
+ "@types/node": "^25.0.10",
29
+ "boxen": "^8.0.1",
30
+ "chalk": "^5.6.2"
31
+ },
32
+ "devDependencies": {
33
+ "@eslint/compat": "^2.0.1",
34
+ "@typescript-eslint/parser": "^8.54.0",
35
+ "eslint": "^9.39.2",
36
+ "eslint-plugin-unused-imports": "^4.3.0",
37
+ "prettier": "^3.8.1",
38
+ "typescript": "^5.9.3"
39
+ }
40
+ }