kailogger 1.0.0-dark.red → 1.0.2

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.
Files changed (102) hide show
  1. package/README.md +195 -53
  2. package/dist/core/Config.d.ts +15 -0
  3. package/dist/core/Config.js +44 -0
  4. package/dist/core/Logger.d.ts +75 -4
  5. package/dist/core/Logger.js +375 -47
  6. package/dist/core/Scope.d.ts +13 -0
  7. package/dist/core/Scope.js +36 -0
  8. package/dist/features/Chart.d.ts +15 -0
  9. package/dist/features/Chart.js +64 -0
  10. package/dist/features/Diff.d.ts +3 -0
  11. package/dist/features/Diff.js +30 -0
  12. package/dist/features/Encrypt.d.ts +10 -0
  13. package/dist/features/Encrypt.js +47 -0
  14. package/dist/features/Notify.d.ts +14 -0
  15. package/dist/features/Notify.js +70 -0
  16. package/dist/features/Screenshot.d.ts +10 -0
  17. package/dist/features/Screenshot.js +106 -0
  18. package/dist/features/Sound.d.ts +12 -0
  19. package/dist/features/Sound.js +116 -0
  20. package/dist/features/Timer.d.ts +6 -0
  21. package/dist/features/Timer.js +38 -0
  22. package/dist/features/Tree.d.ts +7 -0
  23. package/dist/features/Tree.js +25 -0
  24. package/dist/features/index.d.ts +8 -0
  25. package/dist/features/index.js +24 -0
  26. package/dist/icon/logo.png +0 -0
  27. package/dist/index.d.ts +13 -1
  28. package/dist/index.js +21 -1
  29. package/dist/sounds/error.wav +0 -0
  30. package/dist/sounds/notification.wav +0 -0
  31. package/dist/sounds/success.wav +0 -0
  32. package/dist/sounds/warning.wav +0 -0
  33. package/dist/styles/KaiChroma.d.ts +85 -0
  34. package/dist/styles/KaiChroma.js +407 -0
  35. package/dist/styles/gradients.d.ts +28 -0
  36. package/dist/styles/palettes.d.ts +21 -26
  37. package/dist/styles/palettes.js +167 -13
  38. package/dist/transports/ConsoleTransport.d.ts +9 -0
  39. package/dist/transports/ConsoleTransport.js +18 -0
  40. package/dist/transports/FileTransport.d.ts +16 -0
  41. package/dist/transports/FileTransport.js +84 -0
  42. package/dist/transports/WebhookTransport.d.ts +15 -0
  43. package/dist/transports/WebhookTransport.js +31 -0
  44. package/dist/transports/index.d.ts +3 -0
  45. package/dist/transports/index.js +19 -0
  46. package/dist/types/index.d.ts +16 -0
  47. package/dist/types/index.js +11 -0
  48. package/dist/utils/json.d.ts +3 -0
  49. package/dist/utils/json.js +33 -0
  50. package/dist/utils/prettyError.d.ts +3 -0
  51. package/dist/utils/prettyError.js +94 -0
  52. package/dist/utils/progress.d.ts +11 -0
  53. package/dist/utils/progress.js +43 -0
  54. package/dist/utils/prompt.d.ts +4 -0
  55. package/dist/utils/prompt.js +59 -0
  56. package/dist/utils/selection.d.ts +4 -0
  57. package/dist/utils/selection.js +156 -0
  58. package/dist/utils/spinner.d.ts +1 -1
  59. package/dist/utils/spinner.js +9 -13
  60. package/dist/utils/stripAnsi.d.ts +1 -0
  61. package/dist/utils/stripAnsi.js +7 -0
  62. package/dist/utils/table.d.ts +3 -0
  63. package/dist/utils/table.js +35 -0
  64. package/examples/demo.js +134 -0
  65. package/examples/demo.ts +88 -25
  66. package/package.json +20 -6
  67. package/scripts/copy-assets.js +37 -0
  68. package/src/core/Config.ts +44 -0
  69. package/src/core/Logger.ts +427 -51
  70. package/src/core/Scope.ts +35 -0
  71. package/src/features/Chart.ts +81 -0
  72. package/src/features/Diff.ts +25 -0
  73. package/src/features/Encrypt.ts +47 -0
  74. package/src/features/Notify.ts +39 -0
  75. package/src/features/Screenshot.ts +70 -0
  76. package/src/features/Sound.ts +92 -0
  77. package/src/features/Timer.ts +35 -0
  78. package/src/features/Tree.ts +25 -0
  79. package/src/features/index.ts +8 -0
  80. package/src/icon/logo.png +0 -0
  81. package/src/index.ts +13 -1
  82. package/src/sounds/error.wav +0 -0
  83. package/src/sounds/notification.wav +0 -0
  84. package/src/sounds/success.wav +0 -0
  85. package/src/sounds/warning.wav +0 -0
  86. package/src/styles/KaiChroma.ts +370 -0
  87. package/src/styles/palettes.ts +197 -14
  88. package/src/transports/ConsoleTransport.ts +19 -0
  89. package/src/transports/FileTransport.ts +55 -0
  90. package/src/transports/WebhookTransport.ts +37 -0
  91. package/src/transports/index.ts +3 -0
  92. package/src/types/cli-highlight.d.ts +3 -0
  93. package/src/types/index.ts +23 -0
  94. package/src/utils/json.ts +33 -0
  95. package/src/utils/prettyError.ts +65 -0
  96. package/src/utils/progress.ts +56 -0
  97. package/src/utils/prompt.ts +27 -0
  98. package/src/utils/selection.ts +136 -0
  99. package/src/utils/spinner.ts +11 -7
  100. package/src/utils/stripAnsi.ts +6 -0
  101. package/src/utils/table.ts +38 -0
  102. package/src/styles/gradients.ts +0 -22
package/README.md CHANGED
@@ -1,19 +1,31 @@
1
- # 🌸 KaiLogger
1
+ # KaiLogger
2
2
 
3
- > The most **divine**, **beautiful**, and **elegant** logger for Node.js.
4
- > Experience logging like never before with mesmerizing gradients, smooth animations, and a developer experience that feels like Zen.
3
+ > The Ultimate Logger for Node.js — Beautiful, powerful, and designed for developers who care about aesthetics.
5
4
 
6
- ![KaiLogger](https://img.shields.io/npm/v/kailogger?style=for-the-badge&color=ff69b4)
7
- ![TypeScript](https://img.shields.io/badge/Written%20In-TypeScript-blue?style=for-the-badge)
8
- ![License](https://img.shields.io/npm/l/kailogger?style=for-the-badge&color=green)
5
+ <p align="center">
6
+ <img src="https://files.catbox.moe/et33ah.png" alt="KaiLogger Logo" width="600" />
7
+ </p>
8
+
9
+ ![Version](https://img.shields.io/badge/version-1.0.2-blue)
10
+ ![TypeScript](https://img.shields.io/badge/TypeScript-Ready-3178C6)
11
+
12
+ Turn your boring console logs into a cyber-aesthetic experience. KaiLogger is a complete CLI toolkit featuring a custom high-performance color engine (KaiChroma) with TrueColor support, gradients, and 14 built-in themes.
13
+
14
+ ---
9
15
 
10
16
  ## Features
11
17
 
12
- - » **Divine Gradients**: Make your logs pop with stunning, automatically applied color gradients.
13
- - » **Beautiful Themes**: Switch between `Zen` (Nature), `Neon` (Cyberpunk), and `Pastel` (Soft) modes.
14
- - » **Smooth Animations**: Built-in loading spinners that just work.
15
- - » **High Performance**: Minimal overhead, maximum beauty.
16
- - » **TypeScript Native**: Fully typed for a superior developer experience.
18
+ | Category | Features |
19
+ | --------------- | -------------------------------------------------------------- |
20
+ | **Logging** | Log levels, scoped loggers, custom badges, silent mode |
21
+ | **Styling** | **14 Themes**, custom gradients, KaiChroma engine (TrueColor) |
22
+ | **Interactive** | Spinners, progress bars, select menus, prompts |
23
+ | **Debug** | Pretty errors, JSON highlighting, diff view, tree view |
24
+ | **Visuals** | **Charts** (Bar, Sparkline, Gauge), **Screenshots** (TXT/HTML) |
25
+ | **System** | **Desktop Notifications**, **Encryption**, **Sound Alerts** |
26
+ | **Transports** | Console, File (with rotation), Webhooks |
27
+
28
+ ---
17
29
 
18
30
  ## Installation
19
31
 
@@ -21,66 +33,196 @@
21
33
  npm install kailogger
22
34
  ```
23
35
 
24
- ## Usage
36
+ ---
25
37
 
26
- Using KaiLogger is as simple as breathing.
38
+ ## Quick Start
27
39
 
28
40
  ```typescript
29
- import { kai } from 'kailogger';
30
-
31
- // 🌿 Standard Logging
32
- kai.success('Database connected successfully');
33
- kai.info('Server started on port 3000');
34
- kai.warning('Memory usage is slightly elevated');
35
- kai.error('Connection to Redis failed');
36
- kai.debug('User payload received');
37
-
38
- // 🌀 Loading Animations
39
- kai.await('Connecting to the quantum realm...');
40
-
41
- setTimeout(() => {
42
- kai.stop('Connection established!');
43
- // or kai.stop() to just clear the spinner
44
- }, 2000);
41
+ import { kai } from "kailogger";
42
+
43
+ kai.success("Hello, beautiful world!");
44
+ kai.error("Something went wrong");
45
+ kai.warning("Careful there");
46
+ kai.info("Just FYI");
47
+ kai.debug("For your eyes only");
48
+
49
+ // Enable sound
50
+ kai.beep();
45
51
  ```
46
52
 
53
+ ---
54
+
47
55
  ## Themes
48
56
 
49
- Match your mood or your terminal's aesthetic.
57
+ Switch between 14 stunning themes powered by our custom KaiChroma engine.
58
+
59
+ ```typescript
60
+ kai.setTheme("cyberpunk");
61
+ ```
62
+
63
+ **Available Themes:**
64
+
65
+ - `zen` (Minimalist)
66
+ - `neon` (Bright cyber)
67
+ - `pastel` (Soft colors)
68
+ - `hacker` (Matrix style)
69
+ - `sunset` (Warm gradients)
70
+ - `ocean` (Blue/Green tones)
71
+ - `cyberpunk` (Blue/Pink/Yellow)
72
+ - `dracula` (Dark mode favorite)
73
+ - `monokai` (Classic code style)
74
+ - `vaporwave` (Aesthetic purple/cyan)
75
+ - `midnight` (Deep blues)
76
+ - `forest` (Nature tones)
77
+ - `volcano` (Fiery reds/oranges)
78
+ - `gold` (Luxury)
79
+
80
+ ---
81
+
82
+ ## Charts
83
+
84
+ Visualize data directly in your terminal.
85
+
86
+ **Bar Chart**
87
+
88
+ ```typescript
89
+ kai.chart([
90
+ { label: "Users", value: 1500 },
91
+ { label: "Sales", value: 890 },
92
+ { label: "Errors", value: 32 },
93
+ ]);
94
+ ```
95
+
96
+ **Sparkline**
97
+
98
+ ```typescript
99
+ kai.sparkline([10, 25, 40, 35, 60, 90, 45, 20]);
100
+ // Output: ▂▃▄▃▅▇▄▂
101
+ ```
102
+
103
+ **Gauge**
104
+
105
+ ```typescript
106
+ kai.gauge(75, 100, "CPU");
107
+ // CPU: [███████████████░░░░░] 75%
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Notifications & Sounds
113
+
114
+ **Desktop Notifications**
115
+ Send native system notifications.
116
+
117
+ ```typescript
118
+ kai.notify("Build complete!", "Success");
119
+ ```
120
+
121
+ **Sound Alerts**
122
+ Play sounds for events (Success, Error, Warning, Notification).
50
123
 
51
- ### **Zen Mode** (Default)
52
- Calming greens, blues, and nature-inspired gradients.
53
124
  ```typescript
54
- kai.setTheme('zen');
55
- kai.info('Nature is efficient.');
125
+ // Optional: Set custom sounds directory
126
+ kai.setSoundsDir("./src/sounds");
127
+
128
+ await kai.soundSuccess();
129
+ await kai.soundError();
130
+ kai.playSound("custom.wav");
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Encryption
136
+
137
+ Handle sensitive data securely.
138
+
139
+ ```typescript
140
+ // Mask sensitive info in logs
141
+ kai.masked("API Key", "sk-1234567890abcdef", 4);
142
+ // API Key: ************cdef
143
+
144
+ // Encrypt/Decrypt helpers
145
+ const secret = kai.encrypted("My Secret Data", "my-key");
146
+ kai.decrypted(secret, "my-key");
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Screen Capture
152
+
153
+ Capture terminal output to file.
154
+
155
+ ```typescript
156
+ kai.startCapture();
157
+
158
+ kai.success("This will be captured");
159
+ kai.info("So will this");
160
+
161
+ kai.saveScreenshot("logs/session.txt");
162
+ kai.saveScreenshotHtml("logs/session.html"); // Saves as styled HTML!
163
+ ```
164
+
165
+ ---
166
+
167
+ ## Log Levels & Scopes
168
+
169
+ ```typescript
170
+ // Set global level
171
+ kai.setLevel("warning");
172
+
173
+ // Scoped Logger
174
+ const db = kai.scope("Database");
175
+ db.info("Connected"); // [Database] Connected
56
176
  ```
57
177
 
58
- ### **Neon Mode**
59
- High-contrast, cyberpunk-inspired bright colors.
178
+ ---
179
+
180
+ ## Tree & Diff View
181
+
60
182
  ```typescript
61
- kai.setTheme('neon');
62
- kai.info('System override active.');
183
+ // Tree View
184
+ kai.tree({
185
+ src: { "index.ts": null, utils: { "helper.ts": null } },
186
+ });
187
+
188
+ // Diff View
189
+ kai.diff({ status: "idle" }, { status: "active" });
63
190
  ```
64
191
 
65
- ### **Pastel Mode**
66
- Soft, easy-on-the-eyes colors for a gentle experience.
192
+ ---
193
+
194
+ ## Interactive Prompts
195
+
67
196
  ```typescript
68
- kai.setTheme('pastel');
69
- kai.info('Soft cloud computing.');
197
+ const name = await kai.ask("Name?");
198
+ const framework = await kai.select("Framework", ["React", "Vue", "Svelte"]);
199
+
200
+ // Progress Bar
201
+ const bar = kai.createProgress(100);
202
+ bar.update(50);
70
203
  ```
71
204
 
72
- ## API Reference
205
+ ---
206
+
207
+ ## Transports
208
+
209
+ ```typescript
210
+ kai.addFileTransport({
211
+ filename: "./logs/app.log",
212
+ maxSize: 10 * 1024 * 1024,
213
+ });
214
+
215
+ kai.addWebhookTransport({
216
+ url: "https://webhook.site/...",
217
+ });
218
+ ```
73
219
 
74
- - » `kai.success(msg)`: Log a success message.
75
- - » `kai.error(msg)`: Log an error message.
76
- - » `kai.warning(msg)`: Log a warning.
77
- - » `kai.info(msg)`: Log an info message.
78
- - » `kai.debug(msg)`: Log a debug message.
79
- - » `kai.log(msg)`: detailed log without level badge.
80
- - » `kai.box(title, msg)`: Print a message inside a beautiful box.
81
- - » `kai.await(msg)`: Start a loading spinner.
82
- - » `kai.stop(msg?)`: Stop the spinner (optional: replace with a success message).
220
+ ---
83
221
 
84
222
  ## License
85
223
 
86
- MIT © Soblend
224
+ ISC
225
+
226
+ ---
227
+
228
+ **By Soblend Development Studio**
@@ -0,0 +1,15 @@
1
+ import { KaiConfig, Transport } from '../types';
2
+ declare class ConfigManager {
3
+ private static instance;
4
+ private config;
5
+ private constructor();
6
+ static getInstance(): ConfigManager;
7
+ configure(options: Partial<KaiConfig>): void;
8
+ get<K extends keyof KaiConfig>(key: K): KaiConfig[K];
9
+ getAll(): KaiConfig;
10
+ reset(): void;
11
+ addTransport(transport: Transport): void;
12
+ removeTransport(name: string): void;
13
+ }
14
+ export declare const config: ConfigManager;
15
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.config = void 0;
4
+ const DEFAULT_CONFIG = {
5
+ theme: 'zen',
6
+ level: 'debug',
7
+ timestamp: 'locale',
8
+ silent: false,
9
+ transports: []
10
+ };
11
+ class ConfigManager {
12
+ constructor() {
13
+ this.config = { ...DEFAULT_CONFIG };
14
+ }
15
+ static getInstance() {
16
+ if (!ConfigManager.instance) {
17
+ ConfigManager.instance = new ConfigManager();
18
+ }
19
+ return ConfigManager.instance;
20
+ }
21
+ configure(options) {
22
+ this.config = { ...this.config, ...options };
23
+ }
24
+ get(key) {
25
+ return this.config[key];
26
+ }
27
+ getAll() {
28
+ return { ...this.config };
29
+ }
30
+ reset() {
31
+ this.config = { ...DEFAULT_CONFIG };
32
+ }
33
+ addTransport(transport) {
34
+ if (!this.config.transports)
35
+ this.config.transports = [];
36
+ this.config.transports.push(transport);
37
+ }
38
+ removeTransport(name) {
39
+ if (this.config.transports) {
40
+ this.config.transports = this.config.transports.filter(t => t.name !== name);
41
+ }
42
+ }
43
+ }
44
+ exports.config = ConfigManager.getInstance();
@@ -1,20 +1,91 @@
1
1
  import { ThemeName } from '../styles/palettes';
2
+ import { KaiProgress } from '../utils/progress';
3
+ import { ScopedLogger } from './Scope';
4
+ import { LogLevel } from '../types';
5
+ import { FileTransportOptions } from '../transports/FileTransport';
6
+ import { WebhookTransportOptions } from '../transports/WebhookTransport';
7
+ interface LoggerOptions {
8
+ theme?: ThemeName;
9
+ level?: LogLevel;
10
+ logFile?: string;
11
+ silent?: boolean;
12
+ timestamp?: 'ISO' | 'locale' | 'relative' | 'none';
13
+ }
2
14
  export declare class KaiLogger {
3
- theme: ThemeName;
4
15
  private spinner;
5
- constructor(theme?: ThemeName);
16
+ private timer;
17
+ private logFilePath?;
18
+ private buffer;
19
+ private startTime;
20
+ theme: ThemeName;
21
+ level: LogLevel;
22
+ silent: boolean;
23
+ timestampFormat: 'ISO' | 'locale' | 'relative' | 'none';
24
+ constructor(options?: LoggerOptions | ThemeName);
25
+ configure(options: Partial<LoggerOptions>): void;
6
26
  setTheme(theme: ThemeName): void;
27
+ setLevel(level: LogLevel): void;
28
+ setSilent(silent: boolean): void;
29
+ addFileTransport(options: FileTransportOptions): void;
30
+ addWebhookTransport(options: WebhookTransportOptions): void;
31
+ removeTransport(name: string): void;
32
+ scope(name: string): ScopedLogger;
7
33
  private getTime;
8
- private format;
34
+ private shouldLog;
35
+ private logToFile;
36
+ private addToBuffer;
37
+ getBuffer(): string[];
38
+ clearBuffer(): void;
39
+ private print;
9
40
  success(message: string, ...args: any[]): void;
10
- error(message: string, ...args: any[]): void;
41
+ error(message: string | Error, ...args: any[]): void;
11
42
  warning(message: string, ...args: any[]): void;
12
43
  info(message: string, ...args: any[]): void;
13
44
  debug(message: string, ...args: any[]): void;
14
45
  log(message: string): void;
46
+ custom(badge: string, color: string, message: string, ...args: any[]): void;
15
47
  box(title: string, message: string): void;
16
48
  await(message: string): void;
17
49
  stop(message?: string): void;
18
50
  private stopSpinner;
51
+ createProgress(total: number, width?: number): KaiProgress;
52
+ table(data: any[]): void;
53
+ json(data: any): void;
54
+ tree(data: any): void;
55
+ diff(before: any, after: any): void;
56
+ time(label: string): void;
57
+ timeEnd(label: string): number | null;
58
+ ask(question: string): Promise<string>;
59
+ confirm(question: string): Promise<boolean>;
60
+ select(question: string, options: string[]): Promise<string>;
61
+ multiselect(question: string, options: string[]): Promise<string[]>;
62
+ chart(data: {
63
+ label: string;
64
+ value: number;
65
+ }[], options?: {
66
+ width?: number;
67
+ showValues?: boolean;
68
+ }): void;
69
+ sparkline(values: number[]): void;
70
+ gauge(value: number, max: number, label?: string): void;
71
+ notify(message: string, title?: string): void;
72
+ notifySuccess(message: string): void;
73
+ notifyError(message: string): void;
74
+ startCapture(): void;
75
+ stopCapture(): string[];
76
+ saveScreenshot(filename: string): void;
77
+ saveScreenshotHtml(filename: string): void;
78
+ setEncryptionKey(key: string): void;
79
+ encrypted(message: string, key?: string): void;
80
+ decrypted(encryptedMessage: string, key?: string): void;
81
+ masked(label: string, value: string, showLast?: number): void;
82
+ setSoundsDir(dir: string): void;
83
+ beep(): void;
84
+ soundSuccess(): Promise<void>;
85
+ soundError(): Promise<void>;
86
+ soundWarning(): Promise<void>;
87
+ soundNotification(): Promise<void>;
88
+ playSound(filename: string): Promise<void>;
19
89
  }
20
90
  export declare const kai: KaiLogger;
91
+ export {};