@virtualdisplay.io/client 3.7.0 â 4.0.0-alpha.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.
- package/CHANGELOG.md +44 -76
- package/LICENSE +1 -1
- package/README.md +374 -31
- package/dist/index.d.ts +0 -820
- package/dist/virtualdisplay.client.cjs.js +1 -8
- package/dist/virtualdisplay.client.es.js +794 -8022
- package/dist/virtualdisplay.client.umd.js +1 -8
- package/package.json +14 -98
- package/README.npm.md +0 -78
- package/dist/virtualdisplay.client.cjs.js.map +0 -1
- package/dist/virtualdisplay.client.es.js.map +0 -1
- package/dist/virtualdisplay.client.umd.js.map +0 -1
- package/node_modules/@virtualdisplay-io/logger/CHANGELOG.md +0 -82
- package/node_modules/@virtualdisplay-io/logger/LICENSE +0 -21
- package/node_modules/@virtualdisplay-io/logger/README.md +0 -314
- package/node_modules/@virtualdisplay-io/logger/dist/index.d.ts +0 -167
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.cjs.js +0 -4
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.cjs.js.map +0 -1
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.es.js +0 -377
- package/node_modules/@virtualdisplay-io/logger/dist/virtualdisplay.logger.es.js.map +0 -1
- package/node_modules/@virtualdisplay-io/logger/package.json +0 -79
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# [1.2.0](https://github.com/virtualdisplay-io/logger/compare/v1.1.2...v1.2.0) (2025-06-13)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Features
|
|
5
|
-
|
|
6
|
-
* simplify logger API by removing environment detection ([#11](https://github.com/virtualdisplay-io/logger/issues/11)) ([8580f93](https://github.com/virtualdisplay-io/logger/commit/8580f93eb2b9eb7dd6fc6b4ae90b5512ac9b55bc))
|
|
7
|
-
|
|
8
|
-
## [1.1.2](https://github.com/virtualdisplay-io/logger/compare/v1.1.1...v1.1.2) (2025-06-08)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* resolve linting issues in console-transport ([#8](https://github.com/virtualdisplay-io/logger/issues/8)) ([10b8f1a](https://github.com/virtualdisplay-io/logger/commit/10b8f1adaf3ed04efb6c46ace9194f39c8d60b00))
|
|
14
|
-
|
|
15
|
-
## [1.1.1](https://github.com/virtualdisplay-io/logger/compare/v1.1.0...v1.1.1) (2025-06-08)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
20
|
-
* remove hardcoded VirtualDisplay prefix from console transport ([f3734d5](https://github.com/virtualdisplay-io/logger/commit/f3734d5f3b66c9a1e190a13e7c91f9021543324c))
|
|
21
|
-
|
|
22
|
-
# [1.1.0](https://github.com/virtualdisplay-io/logger/compare/v1.0.1...v1.1.0) (2025-06-08)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Features
|
|
26
|
-
|
|
27
|
-
* update semantic-release config to match client library ([ec76794](https://github.com/virtualdisplay-io/logger/commit/ec7679460926ec5423fad52a9859ef34d547a9ef))
|
|
28
|
-
|
|
29
|
-
## [1.0.1](https://github.com/virtualdisplay-io/logger/compare/v1.0.0...v1.0.1) (2025-06-08)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Bug Fixes
|
|
33
|
-
|
|
34
|
-
* ensure production build is created before release ([#7](https://github.com/virtualdisplay-io/logger/issues/7)) ([459af10](https://github.com/virtualdisplay-io/logger/commit/459af105c3e6e123b75f4cb96bbaa5c89722fdb8))
|
|
35
|
-
|
|
36
|
-
# 1.0.0 (2025-06-08)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Features
|
|
40
|
-
|
|
41
|
-
* initial Virtual Display Logger implementation ([dcbda81](https://github.com/virtualdisplay-io/logger/commit/dcbda81cf31a097eed8df61a6d5294a8b0d9f1c4))
|
|
42
|
-
|
|
43
|
-
# Changelog
|
|
44
|
-
|
|
45
|
-
All notable changes to this project will be documented in this file.
|
|
46
|
-
|
|
47
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
48
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
49
|
-
|
|
50
|
-
## [Unreleased]
|
|
51
|
-
|
|
52
|
-
### Added
|
|
53
|
-
- Initial release of @virtualdisplay-io/logger
|
|
54
|
-
- Core logging functionality with debug, info, warn, error levels
|
|
55
|
-
- Singleton pattern with Logger.getInstance()
|
|
56
|
-
- Child logger support with context inheritance
|
|
57
|
-
- Multiple transport system (Console, Memory)
|
|
58
|
-
- Formatter system (Context, JSON)
|
|
59
|
-
- Environment-aware logging
|
|
60
|
-
- Test environment auto-detection
|
|
61
|
-
- TypeScript support with full type definitions
|
|
62
|
-
- Comprehensive test suite with 100% coverage
|
|
63
|
-
- Zero dependencies
|
|
64
|
-
- Browser and Node.js compatibility
|
|
65
|
-
- Memory transport with querying and export capabilities
|
|
66
|
-
- Global muting functionality
|
|
67
|
-
- Configurable log levels and filtering
|
|
68
|
-
|
|
69
|
-
### Features
|
|
70
|
-
- **ConsoleTransport**: Console output with colors and timestamps
|
|
71
|
-
- **MemoryTransport**: In-memory log storage with search and export
|
|
72
|
-
- **ContextFormatter**: Appends context data to messages
|
|
73
|
-
- **JSONFormatter**: Full JSON serialization of log entries
|
|
74
|
-
- **Child Loggers**: Hierarchical logging with context merging
|
|
75
|
-
- **Smart Environment Detection**: Automatic test environment detection
|
|
76
|
-
- **Performance Optimized**: Zero runtime dependencies, efficient memory usage
|
|
77
|
-
- **Developer Experience**: Comprehensive TypeScript types, clear API
|
|
78
|
-
|
|
79
|
-
## [1.0.0] - 2025-01-XX
|
|
80
|
-
|
|
81
|
-
### Added
|
|
82
|
-
- Initial stable release
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Virtual Display
|
|
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.
|
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
# @virtualdisplay-io/logger
|
|
2
|
-
|
|
3
|
-
A simple, TypeScript-first logging library for browser and Node.js applications.
|
|
4
|
-
|
|
5
|
-
[](https://github.com/virtualdisplay-io/logger/packages)
|
|
6
|
-
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://www.typescriptlang.org/)
|
|
8
|
-
|
|
9
|
-
## Features
|
|
10
|
-
|
|
11
|
-
- **Simple API** - Just `enabled` and `level`, no complex configuration
|
|
12
|
-
- **TypeScript Native** - Full type safety and autocompletion
|
|
13
|
-
- **Lightweight** - ~3KB gzipped, zero dependencies
|
|
14
|
-
- **Visual Clarity** - Emoji indicators and colors for log levels (đ â ī¸ â đ)
|
|
15
|
-
- **Universal** - Works in Node.js, browsers, and workers
|
|
16
|
-
- **Extensible** - Custom transports and formatters
|
|
17
|
-
- **Memory Transport** - Built-in log analysis and debugging
|
|
18
|
-
- **Child Loggers** - Contextual logging with inherited settings
|
|
19
|
-
|
|
20
|
-
## Installation
|
|
21
|
-
|
|
22
|
-
This package is published to GitHub Packages. First, configure your npm to use the GitHub Package Registry:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
echo "@virtualdisplay-io:registry=https://npm.pkg.github.com" >> .npmrc
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Then install the package:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm install @virtualdisplay-io/logger
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
yarn add @virtualdisplay-io/logger
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
pnpm add @virtualdisplay-io/logger
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Quick Start
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
import { logger } from '@virtualdisplay-io/logger';
|
|
46
|
-
|
|
47
|
-
// The default logger has no prefix - clean and neutral
|
|
48
|
-
logger.info('Application started'); // đ Application started
|
|
49
|
-
logger.warn('This is a warning'); // â ī¸ This is a warning
|
|
50
|
-
logger.error('Something went wrong', { userId: '123' }); // â Something went wrong
|
|
51
|
-
|
|
52
|
-
// Create a logger with your own prefix
|
|
53
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
54
|
-
|
|
55
|
-
const appLogger = new Logger({ prefix: 'MyApp' });
|
|
56
|
-
appLogger.info('Application started'); // đ [MyApp] Application started
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Advanced Usage
|
|
60
|
-
|
|
61
|
-
### Simple Configuration
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
65
|
-
|
|
66
|
-
const logger = new Logger({
|
|
67
|
-
prefix: 'MyApp',
|
|
68
|
-
level: 'info', // Only show info, warn, and error
|
|
69
|
-
enabled: true, // Turn logging on/off
|
|
70
|
-
colors: true, // Enable colors in browser (default: true)
|
|
71
|
-
context: { version: '1.0.0' }
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
logger.info('Server started'); // Shows (info level or higher)
|
|
75
|
-
logger.debug('Cache cleared'); // Hidden (below info level)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Control Log Levels
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
// Set level dynamically
|
|
82
|
-
logger.setLevel('debug'); // Now debug messages will show
|
|
83
|
-
logger.setLevel('error'); // Only errors will show
|
|
84
|
-
|
|
85
|
-
// Turn logging on/off
|
|
86
|
-
logger.setEnabled(false); // All logging disabled
|
|
87
|
-
logger.setEnabled(true); // Logging re-enabled
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### Child Loggers
|
|
91
|
-
|
|
92
|
-
```typescript
|
|
93
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
94
|
-
|
|
95
|
-
// Create a base logger without prefix
|
|
96
|
-
const baseLogger = new Logger();
|
|
97
|
-
|
|
98
|
-
// Create child logger with additional context
|
|
99
|
-
const authLogger = baseLogger.child({
|
|
100
|
-
prefix: 'Auth',
|
|
101
|
-
context: { module: 'authentication' },
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const userLogger = authLogger.child({
|
|
105
|
-
context: { userId: '123', action: 'login' },
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
userLogger.info('User login attempt');
|
|
109
|
-
// Output: [timestamp] [Auth] INFO: User login attempt {module="authentication" userId="123" action="login"}
|
|
110
|
-
|
|
111
|
-
// Or add a prefix to the default logger
|
|
112
|
-
import { logger } from '@virtualdisplay-io/logger';
|
|
113
|
-
const apiLogger = logger.child({ prefix: 'API', context: { service: 'users' } });
|
|
114
|
-
// Output will have [API] prefix
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
### Custom Formatters
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
122
|
-
import type { LogFormatter, LogEntry } from '@virtualdisplay-io/logger';
|
|
123
|
-
|
|
124
|
-
class CustomFormatter implements LogFormatter {
|
|
125
|
-
name = 'custom';
|
|
126
|
-
|
|
127
|
-
format(entry: LogEntry): LogEntry {
|
|
128
|
-
return {
|
|
129
|
-
...entry,
|
|
130
|
-
message: `đ¯ ${entry.message.toUpperCase()}`,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const logger = new Logger({
|
|
136
|
-
formatters: [new CustomFormatter()],
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
logger.info('hello world'); // Output: đ¯ HELLO WORLD
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
### Memory Transport for Log Analysis
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
146
|
-
|
|
147
|
-
// Memory transport is loaded dynamically to keep bundle size small
|
|
148
|
-
const logger = new Logger();
|
|
149
|
-
|
|
150
|
-
// Enable memory logging when needed
|
|
151
|
-
await logger.enableMemoryLogging(500); // Store max 500 entries
|
|
152
|
-
|
|
153
|
-
// Log some events
|
|
154
|
-
logger.info('User created', { userId: '123' });
|
|
155
|
-
logger.warn('Rate limit exceeded', { ip: '192.168.1.1' });
|
|
156
|
-
logger.error('Database connection failed');
|
|
157
|
-
|
|
158
|
-
// Use the logger's debug methods to analyze logs
|
|
159
|
-
const allLogs = JSON.parse(logger.exportLogs());
|
|
160
|
-
const errors = logger.getRecentErrors();
|
|
161
|
-
const searchResults = logger.searchLogs(/database/i);
|
|
162
|
-
|
|
163
|
-
// Export logs
|
|
164
|
-
console.log(logger.exportLogs()); // JSON format
|
|
165
|
-
console.log(logger.exportLogsCSV()); // CSV format
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
### Global Muting
|
|
169
|
-
|
|
170
|
-
```typescript
|
|
171
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
172
|
-
|
|
173
|
-
// Mute all logger instances
|
|
174
|
-
Logger.setMute(true);
|
|
175
|
-
logger.info('This will not be logged');
|
|
176
|
-
|
|
177
|
-
// Unmute
|
|
178
|
-
Logger.setMute(false);
|
|
179
|
-
logger.info('This will be logged');
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
## API Reference
|
|
183
|
-
|
|
184
|
-
### Logger Class
|
|
185
|
-
|
|
186
|
-
#### Basic methods:
|
|
187
|
-
- `debug(message: string, ...args: unknown[]): void`
|
|
188
|
-
- `info(message: string, ...args: unknown[]): void`
|
|
189
|
-
- `warn(message: string, ...args: unknown[]): void`
|
|
190
|
-
- `error(message: string, ...args: unknown[]): void`
|
|
191
|
-
- `child(options?: Partial<LoggerOptions>): Logger`
|
|
192
|
-
|
|
193
|
-
#### Configuration methods:
|
|
194
|
-
- `setLevel(level: LogLevel): void` - Set the minimum log level
|
|
195
|
-
- `getLevel(): LogLevel` - Get the current log level
|
|
196
|
-
- `setEnabled(enabled: boolean): void` - Enable/disable logging
|
|
197
|
-
- `isEnabled(): boolean` - Check if logging is enabled
|
|
198
|
-
|
|
199
|
-
#### Transport & Formatter methods:
|
|
200
|
-
- `addTransport(transport: LogTransport): void`
|
|
201
|
-
- `removeTransport(name: string): void`
|
|
202
|
-
- `getTransport(name: string): LogTransport | undefined`
|
|
203
|
-
- `addFormatter(formatter: LogFormatter): void`
|
|
204
|
-
- `removeFormatter(name: string): void`
|
|
205
|
-
- `getFormatter(name: string): LogFormatter | undefined`
|
|
206
|
-
|
|
207
|
-
#### Debug methods (when memory transport is added):
|
|
208
|
-
- `enableMemoryLogging(maxSize?: number): Promise<void>`
|
|
209
|
-
- `exportLogs(): string` - Export logs as JSON
|
|
210
|
-
- `exportLogsCSV(): string` - Export logs as CSV
|
|
211
|
-
- `getRecentErrors(minutes?: number): LogEntry[]`
|
|
212
|
-
- `searchLogs(query: string | RegExp): LogEntry[]`
|
|
213
|
-
- `clearLogs(): void`
|
|
214
|
-
|
|
215
|
-
### Log Levels
|
|
216
|
-
|
|
217
|
-
- `debug` (0) - Detailed debugging information
|
|
218
|
-
- `info` (1) - General information
|
|
219
|
-
- `warn` (2) - Warning messages
|
|
220
|
-
- `error` (3) - Error messages
|
|
221
|
-
|
|
222
|
-
### Built-in Transports
|
|
223
|
-
|
|
224
|
-
- **ConsoleTransport** - Outputs to console with colors, emojis, and grouped logging
|
|
225
|
-
- Colors for visual clarity (can be disabled)
|
|
226
|
-
- Collapsible groups showing origin and arguments
|
|
227
|
-
- Automatic fallback for environments without color support
|
|
228
|
-
- **MemoryTransport** - Stores logs in memory with query capabilities (loaded on-demand)
|
|
229
|
-
|
|
230
|
-
### Built-in Formatters
|
|
231
|
-
|
|
232
|
-
- **ContextFormatter** - Appends context data to log messages
|
|
233
|
-
- **JSONFormatter** - Converts log entries to JSON format
|
|
234
|
-
|
|
235
|
-
## Browser Support
|
|
236
|
-
|
|
237
|
-
- **Modern browsers** (ES2022+)
|
|
238
|
-
- **Node.js** 18+
|
|
239
|
-
|
|
240
|
-
## Debug Features
|
|
241
|
-
|
|
242
|
-
The logger includes some basic debug features when using the memory transport:
|
|
243
|
-
|
|
244
|
-
```typescript
|
|
245
|
-
import { logger } from '@virtualdisplay-io/logger';
|
|
246
|
-
|
|
247
|
-
// Enable memory logging to store logs
|
|
248
|
-
await logger.enableMemoryLogging(1000); // Store max 1000 log entries
|
|
249
|
-
|
|
250
|
-
// Export logs as JSON
|
|
251
|
-
const logs = logger.exportLogs();
|
|
252
|
-
|
|
253
|
-
// Export logs as CSV
|
|
254
|
-
const csv = logger.exportLogsCSV();
|
|
255
|
-
|
|
256
|
-
// Get recent errors
|
|
257
|
-
const errors = logger.getRecentErrors();
|
|
258
|
-
|
|
259
|
-
// Search logs
|
|
260
|
-
const searchResults = logger.searchLogs('search term');
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
## Basic Example
|
|
265
|
-
|
|
266
|
-
```typescript
|
|
267
|
-
import { Logger } from '@virtualdisplay-io/logger';
|
|
268
|
-
|
|
269
|
-
// Create a logger for your application
|
|
270
|
-
const appLogger = new Logger({ prefix: 'MyApp' });
|
|
271
|
-
|
|
272
|
-
// Log some messages
|
|
273
|
-
appLogger.info('Application started');
|
|
274
|
-
appLogger.warn('This is a warning');
|
|
275
|
-
appLogger.error('An error occurred');
|
|
276
|
-
|
|
277
|
-
// Create child loggers with context
|
|
278
|
-
const userLogger = appLogger.child({
|
|
279
|
-
context: { userId: '123', module: 'auth' }
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
userLogger.info('User logged in');
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
## Examples
|
|
286
|
-
|
|
287
|
-
The `examples/` directory contains focused examples for each feature:
|
|
288
|
-
|
|
289
|
-
- **`basic-usage.ts`** - Getting started, log levels, prefixes
|
|
290
|
-
- **`child-loggers.ts`** - Hierarchical logging with context inheritance
|
|
291
|
-
- **`memory-transport.ts`** - Log analysis and debugging commands
|
|
292
|
-
- **`custom-colors.ts`** - Customize visual appearance
|
|
293
|
-
- **`custom-transports.ts`** - Create your own logging destinations
|
|
294
|
-
- **`formatters.ts`** - Transform log messages before output
|
|
295
|
-
- **`grouped-logging.ts`** - Collapsible browser console groups
|
|
296
|
-
- **`advanced-usage.ts`** - Multiple features working together
|
|
297
|
-
- **`production-setup.ts`** - Real-world production configuration
|
|
298
|
-
|
|
299
|
-
Run any example with:
|
|
300
|
-
```bash
|
|
301
|
-
npx tsx examples/basic-usage.ts
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
## Contributing
|
|
305
|
-
|
|
306
|
-
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
307
|
-
|
|
308
|
-
## License
|
|
309
|
-
|
|
310
|
-
MIT Š [Virtual Display](LICENSE)
|
|
311
|
-
|
|
312
|
-
---
|
|
313
|
-
|
|
314
|
-
Built with â¤ī¸ by the Virtual Display team
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
export declare class ConsoleTransport implements LogTransport {
|
|
2
|
-
readonly name = "console";
|
|
3
|
-
private readonly colorMap;
|
|
4
|
-
private readonly emojiMap;
|
|
5
|
-
constructor(_options?: ConsoleTransportOptions);
|
|
6
|
-
log(entry: LogEntry): void;
|
|
7
|
-
private createStackTrace;
|
|
8
|
-
private getConsoleMethod;
|
|
9
|
-
private supportsGroupedLogging;
|
|
10
|
-
private isTestEnvironment;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export declare interface ConsoleTransportOptions {
|
|
14
|
-
colors?: boolean;
|
|
15
|
-
timestamp?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export declare class ContextFormatter implements LogFormatter {
|
|
19
|
-
readonly name = "context";
|
|
20
|
-
private readonly includeContext;
|
|
21
|
-
private readonly contextPrefix;
|
|
22
|
-
constructor(options?: ContextFormatterOptions);
|
|
23
|
-
format(entry: LogEntry): LogEntry;
|
|
24
|
-
private formatContext;
|
|
25
|
-
private formatValue;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export declare interface ContextFormatterOptions {
|
|
29
|
-
includeContext?: boolean;
|
|
30
|
-
contextPrefix?: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export declare const enableMemoryLogging: typeof Logger.enableMemoryLogging;
|
|
34
|
-
|
|
35
|
-
export declare interface ILogger {
|
|
36
|
-
debug(message: string, ...args: unknown[]): void;
|
|
37
|
-
info(message: string, ...args: unknown[]): void;
|
|
38
|
-
warn(message: string, ...args: unknown[]): void;
|
|
39
|
-
error(message: string, ...args: unknown[]): void;
|
|
40
|
-
child(options?: Partial<LoggerOptions>): ILogger;
|
|
41
|
-
setLevel(level: LogLevel): void;
|
|
42
|
-
getLevel(): LogLevel;
|
|
43
|
-
isEnabled(): boolean;
|
|
44
|
-
setEnabled(enabled: boolean): void;
|
|
45
|
-
addTransport(transport: LogTransport): void;
|
|
46
|
-
removeTransport(name: string): void;
|
|
47
|
-
addFormatter(formatter: LogFormatter): void;
|
|
48
|
-
removeFormatter(name: string): void;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export declare class JSONFormatter implements LogFormatter {
|
|
52
|
-
readonly name = "json";
|
|
53
|
-
private seen;
|
|
54
|
-
format(entry: LogEntry): LogEntry;
|
|
55
|
-
private sanitizeMessage;
|
|
56
|
-
private sanitizeValue;
|
|
57
|
-
private sanitizeObject;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export declare const LOG_LEVEL_NAMES: Record<LogLevelValue, LogLevel>;
|
|
61
|
-
|
|
62
|
-
export declare const LOG_LEVELS: Record<LogLevel, LogLevelValue>;
|
|
63
|
-
|
|
64
|
-
export declare interface LogEntry {
|
|
65
|
-
level: LogLevel;
|
|
66
|
-
message: string;
|
|
67
|
-
timestamp: Date;
|
|
68
|
-
context?: Record<string, unknown>;
|
|
69
|
-
args?: unknown[];
|
|
70
|
-
prefix?: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export declare interface LogFormatter {
|
|
74
|
-
name: string;
|
|
75
|
-
format(entry: LogEntry): LogEntry;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export declare class Logger implements ILogger {
|
|
79
|
-
private static instance;
|
|
80
|
-
private static mute;
|
|
81
|
-
private readonly prefix?;
|
|
82
|
-
private enabled;
|
|
83
|
-
private level;
|
|
84
|
-
private readonly context;
|
|
85
|
-
private readonly transports;
|
|
86
|
-
private readonly formatters;
|
|
87
|
-
private readonly isRoot;
|
|
88
|
-
constructor(options?: LoggerOptions, isRoot?: boolean);
|
|
89
|
-
static getInstance(options?: LoggerOptions): Logger;
|
|
90
|
-
static setMute(mute: boolean): void;
|
|
91
|
-
static isMuted(): boolean;
|
|
92
|
-
static exportLogs(): string;
|
|
93
|
-
static exportLogsCSV(): string;
|
|
94
|
-
static getRecentErrors(minutes?: number): LogEntry[];
|
|
95
|
-
static searchLogs(query: string | RegExp): LogEntry[];
|
|
96
|
-
static clearLogs(): void;
|
|
97
|
-
static enableMemoryLogging(maxSize?: number): Promise<void>;
|
|
98
|
-
debug(message: string, ...args: unknown[]): void;
|
|
99
|
-
info(message: string, ...args: unknown[]): void;
|
|
100
|
-
warn(message: string, ...args: unknown[]): void;
|
|
101
|
-
error(message: string, ...args: unknown[]): void;
|
|
102
|
-
child(options?: Partial<LoggerOptions>): Logger;
|
|
103
|
-
setLevel(level: LogLevel): void;
|
|
104
|
-
getLevel(): LogLevel;
|
|
105
|
-
isEnabled(): boolean;
|
|
106
|
-
setEnabled(enabled: boolean): void;
|
|
107
|
-
addTransport(transport: LogTransport): void;
|
|
108
|
-
removeTransport(name: string): void;
|
|
109
|
-
addFormatter(formatter: LogFormatter): void;
|
|
110
|
-
removeFormatter(name: string): void;
|
|
111
|
-
getTransport(name: string): LogTransport | undefined;
|
|
112
|
-
getFormatter(name: string): LogFormatter | undefined;
|
|
113
|
-
exportLogs(): string;
|
|
114
|
-
exportLogsCSV(): string;
|
|
115
|
-
getRecentErrors(minutes?: number): LogEntry[];
|
|
116
|
-
searchLogs(query: string | RegExp): LogEntry[];
|
|
117
|
-
clearLogs(): void;
|
|
118
|
-
enableMemoryLogging(maxSize?: number): Promise<void>;
|
|
119
|
-
private getMemoryTransport;
|
|
120
|
-
private log;
|
|
121
|
-
private shouldLog;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export declare const logger: Logger;
|
|
125
|
-
|
|
126
|
-
export declare interface LoggerOptions {
|
|
127
|
-
prefix?: string;
|
|
128
|
-
enabled?: boolean;
|
|
129
|
-
level?: LogLevel;
|
|
130
|
-
timestamp?: boolean;
|
|
131
|
-
colors?: boolean;
|
|
132
|
-
context?: Record<string, unknown>;
|
|
133
|
-
transports?: LogTransport[];
|
|
134
|
-
formatters?: LogFormatter[];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export declare type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
138
|
-
|
|
139
|
-
export declare type LogLevelValue = 0 | 1 | 2 | 3;
|
|
140
|
-
|
|
141
|
-
export declare interface LogTransport {
|
|
142
|
-
name: string;
|
|
143
|
-
log(entry: LogEntry): void | Promise<void>;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
export declare class MemoryTransport implements LogTransport {
|
|
147
|
-
readonly name = "memory";
|
|
148
|
-
private readonly logs;
|
|
149
|
-
private readonly maxSize;
|
|
150
|
-
constructor(options?: MemoryTransportOptions);
|
|
151
|
-
log(entry: LogEntry): void;
|
|
152
|
-
getLogs(): ReadonlyArray<LogEntry>;
|
|
153
|
-
clear(): void;
|
|
154
|
-
getLogsByLevel(level: LogEntry['level']): ReadonlyArray<LogEntry>;
|
|
155
|
-
getLogsAfter(timestamp: Date): ReadonlyArray<LogEntry>;
|
|
156
|
-
getLogsBefore(timestamp: Date): ReadonlyArray<LogEntry>;
|
|
157
|
-
getLogsBetween(start: Date, end: Date): ReadonlyArray<LogEntry>;
|
|
158
|
-
search(query: string | RegExp): ReadonlyArray<LogEntry>;
|
|
159
|
-
toJSON(): string;
|
|
160
|
-
toCSV(): string;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export declare interface MemoryTransportOptions {
|
|
164
|
-
maxSize?: number;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export { }
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=Object.freeze({debug:0,info:1,warn:2,error:3}),u=Object.freeze({0:"debug",1:"info",2:"warn",3:"error"});class m{name="console";colorMap={info:"color: #007bff;",warn:"color: #ffc107;",error:"color: #dc3545;",debug:"color: #28a745;"};emojiMap={info:"đ",warn:"â ī¸",error:"â",debug:"đ"};constructor(e={}){}log(e){const t=this.createStackTrace(),r=this.emojiMap[e.level],o=this.colorMap[e.level],i=e.prefix?`%c[${e.prefix}] ${r} ${e.message}`:`%c${r} ${e.message}`,c=[o];try{if(this.supportsGroupedLogging()){const n=console;n.groupCollapsed(i,...c);const l=this.getConsoleMethod(e.level);l(`Origin: ${t}`),l("Arguments: ",...e.args??[]),n.groupEnd()}else{const n=e.prefix?`[${e.prefix}] ${r} ${e.message}`:`${r} ${e.message}`;this.getConsoleMethod(e.level)(n,...e.args??[])}}catch{try{const n=e.prefix?`[${e.prefix}] ${e.level.toUpperCase()}: ${e.message}`:`${e.level.toUpperCase()}: ${e.message}`;console.log(n,...e.args??[])}catch{}}}createStackTrace(){const e=new Error().stack;if(!e)return"unknown location";const r=e.split(`
|
|
2
|
-
`).find(o=>!o.includes("console-transport.ts")&&!o.includes("logger.ts")&&o.includes("at"));return r?r.trim().replace(/^at\s+/,""):"unknown location"}getConsoleMethod(e){switch(e){case"debug":return console.log;case"info":return console.info;case"warn":return console.warn;case"error":return console.error;default:return console.log}}supportsGroupedLogging(){try{return this.isTestEnvironment()?!1:typeof console.groupCollapsed=="function"&&typeof console.groupEnd=="function"}catch{return!1}}isTestEnvironment(){return typeof window<"u"&&(window.__WTR_CONFIG__!==void 0||window.__karma__!==void 0)?!0:typeof process<"u"&&process.env?process.env.NODE_ENV==="test"||process.env.JEST_WORKER_ID!==void 0||process.env.VITEST==="true":!1}}class f{name="memory";logs=[];maxSize;constructor(e={}){this.maxSize=e.maxSize??1e3}log(e){this.logs.push({...e}),this.logs.length>this.maxSize&&this.logs.shift()}getLogs(){return[...this.logs]}clear(){this.logs.length=0}getLogsByLevel(e){return this.logs.filter(t=>t.level===e)}getLogsAfter(e){return this.logs.filter(t=>t.timestamp>e)}getLogsBefore(e){return this.logs.filter(t=>t.timestamp<e)}getLogsBetween(e,t){return this.logs.filter(r=>r.timestamp>=e&&r.timestamp<=t)}search(e){const t=typeof e=="string"?new RegExp(e,"i"):e;return this.logs.filter(r=>t.test(r.message))}toJSON(){return JSON.stringify(this.logs,null,2)}toCSV(){const e=["timestamp","level","prefix","message","context"],t=this.logs.map(r=>[r.timestamp.toISOString(),r.level,r.prefix??"",r.message,JSON.stringify(r.context??{})]);return[e.join(","),...t.map(r=>r.map(o=>`"${o}"`).join(","))].join(`
|
|
3
|
-
`)}}const p=Object.freeze(Object.defineProperty({__proto__:null,ConsoleTransport:m,MemoryTransport:f},Symbol.toStringTag,{value:"Module"}));class s{static instance;static mute=!1;prefix;enabled;level;context;transports;formatters;isRoot;constructor(e={},t=!0){if(this.prefix=e.prefix,this.enabled=e.enabled??!0,this.level=e.level??"info",this.context=e.context??{},this.transports=new Map,this.formatters=new Map,this.isRoot=t,this.isRoot){const r=new m({colors:e.colors??!0,timestamp:e.timestamp??!1});this.addTransport(r)}e.transports?.forEach(r=>this.addTransport(r)),e.formatters?.forEach(r=>this.addFormatter(r))}static getInstance(e){return s.instance??=new s(e),s.instance}static setMute(e){s.mute=e}static isMuted(){return s.mute}static exportLogs(){return s.getInstance().exportLogs()}static exportLogsCSV(){return s.getInstance().exportLogsCSV()}static getRecentErrors(e){return s.getInstance().getRecentErrors(e)}static searchLogs(e){return s.getInstance().searchLogs(e)}static clearLogs(){s.getInstance().clearLogs()}static enableMemoryLogging(e){return s.getInstance().enableMemoryLogging(e)}debug(e,...t){this.log("debug",e,...t)}info(e,...t){this.log("info",e,...t)}warn(e,...t){this.log("warn",e,...t)}error(e,...t){this.log("error",e,...t)}child(e={}){const t={prefix:e.prefix??this.prefix,enabled:e.enabled??this.enabled,level:e.level??this.level,context:{...this.context,...e.context},transports:Array.from(this.transports.values()),formatters:Array.from(this.formatters.values())};return new s(t,!1)}setLevel(e){this.level=e}getLevel(){return this.level}isEnabled(){return this.enabled&&!s.mute}setEnabled(e){this.enabled=e}addTransport(e){this.transports.set(e.name,e)}removeTransport(e){this.transports.delete(e)}addFormatter(e){this.formatters.set(e.name,e)}removeFormatter(e){this.formatters.delete(e)}getTransport(e){return this.transports.get(e)}getFormatter(e){return this.formatters.get(e)}exportLogs(){const e=this.getMemoryTransport();return e?e.toJSON():JSON.stringify({error:"No memory transport found. Logs are not being stored."})}exportLogsCSV(){const e=this.getMemoryTransport();return e?e.toCSV():"Error: No memory transport found. Logs are not being stored."}getRecentErrors(e=30){const t=this.getMemoryTransport();if(!t)return[];const r=new Date(Date.now()-e*60*1e3);return[...t.getLogsAfter(r).filter(o=>o.level==="error")]}searchLogs(e){const t=this.getMemoryTransport();return t?[...t.search(e)]:[]}clearLogs(){const e=this.getMemoryTransport();e?(e.clear(),console.log("đī¸ Logger memory cleared")):console.log("âšī¸ No memory transport found to clear")}enableMemoryLogging(e=1e3){return Promise.resolve().then(()=>p).then(({MemoryTransport:t})=>{const r=new t({maxSize:e});this.addTransport(r),console.log(`đ Memory logging enabled (max ${e} entries)`),console.log("đĄ Use logger.exportLogs() to get logs as JSON"),console.log("đĄ Use logger.exportLogsCSV() to get logs as CSV"),console.log("đĄ Use logger.getRecentErrors() to get recent errors"),console.log("đĄ Use logger.clearLogs() to clear stored logs")})}getMemoryTransport(){return this.transports.get("memory")}log(e,t,...r){if(!this.shouldLog(e))return;let o={level:e,message:t,timestamp:new Date,context:this.context,args:r,prefix:this.prefix};for(const i of this.formatters.values())o=i.format(o);for(const i of this.transports.values())try{i.log(o)}catch(c){this.isRoot&&console.error("Logger transport error:",c)}}shouldLog(e){if(!this.isEnabled())return!1;const t=g[this.level];return g[e]>=t}}class h{name="json";seen=new WeakSet;format(e){this.seen=new WeakSet;const t={...e,timestamp:e.timestamp.toISOString(),message:this.sanitizeMessage(e.message)};return e.context&&(t.context=this.sanitizeObject(e.context)),e.args&&(t.args=e.args.map(r=>this.sanitizeValue(r))),{...e,message:JSON.stringify(t)}}sanitizeMessage(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}sanitizeValue(e){return e===void 0||e===null?null:typeof e=="function"?"[Function]":typeof e=="symbol"?e.toString():e instanceof Error?{name:e.name,message:e.message,stack:e.stack}:typeof e=="object"?this.sanitizeObject(e):e}sanitizeObject(e){if(this.seen.has(e))return{"[Circular]":!0};this.seen.add(e);const t={};for(const[r,o]of Object.entries(e))try{t[r]=this.sanitizeValue(o)}catch{t[r]="[Unserializable]"}return t}}class d{name="context";includeContext;contextPrefix;constructor(e={}){this.includeContext=e.includeContext??!0,this.contextPrefix=e.contextPrefix??" "}format(e){if(!this.includeContext||!e.context||Object.keys(e.context).length===0)return e;const t=this.formatContext(e.context);return{...e,message:`${e.message}${this.contextPrefix}${t}`}}formatContext(e){return`{${Object.entries(e).map(([r,o])=>`${r}=${this.formatValue(o)}`).join(" ")}}`}formatValue(e){return e===null?"null":e===void 0?"undefined":typeof e=="string"?`"${e}"`:typeof e=="number"||typeof e=="boolean"?String(e):e instanceof Date?e.toISOString():e instanceof Error?`Error(${e.message})`:Array.isArray(e)?`[${e.length}]`:typeof e=="object"?"{...}":JSON.stringify(e)??"unknown"}}const x=s.getInstance(),b=s.enableMemoryLogging.bind(s);exports.ConsoleTransport=m;exports.ContextFormatter=d;exports.JSONFormatter=h;exports.LOG_LEVELS=g;exports.LOG_LEVEL_NAMES=u;exports.Logger=s;exports.MemoryTransport=f;exports.enableMemoryLogging=b;exports.logger=x;
|
|
4
|
-
//# sourceMappingURL=virtualdisplay.logger.cjs.js.map
|