@glideidentity/web-client-sdk 5.0.0 → 5.0.1
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/README.md +108 -8
- package/dist/adapters/angular/index.js +0 -1
- package/dist/adapters/angular/phone-auth.service.d.ts +0 -18
- package/dist/adapters/angular/phone-auth.service.js +0 -26
- package/dist/adapters/react/index.js +0 -3
- package/dist/adapters/react/useClient.js +0 -1
- package/dist/adapters/react/usePhoneAuth.js +1 -16
- package/dist/adapters/vanilla/client.js +0 -1
- package/dist/adapters/vanilla/index.js +0 -1
- package/dist/adapters/vanilla/phone-auth.js +0 -31
- package/dist/adapters/vue/index.js +0 -4
- package/dist/adapters/vue/useClient.js +0 -5
- package/dist/adapters/vue/usePhoneAuth.js +1 -20
- package/dist/browser/web-client-sdk.min.js +1 -1
- package/dist/browser.js +0 -6
- package/dist/core/client.js +0 -12
- package/dist/core/logger.js +1 -81
- package/dist/core/phone-auth/api-types.js +0 -83
- package/dist/core/phone-auth/client.js +27 -366
- package/dist/core/phone-auth/error-utils.js +1 -83
- package/dist/core/phone-auth/index.js +0 -1
- package/dist/core/phone-auth/status-types.d.ts +0 -78
- package/dist/core/phone-auth/status-types.js +0 -17
- package/dist/core/phone-auth/strategies/desktop.js +8 -126
- package/dist/core/phone-auth/strategies/index.d.ts +0 -4
- package/dist/core/phone-auth/strategies/index.js +0 -4
- package/dist/core/phone-auth/strategies/link.js +10 -88
- package/dist/core/phone-auth/strategies/ts43.d.ts +0 -19
- package/dist/core/phone-auth/strategies/ts43.js +2 -33
- package/dist/core/phone-auth/strategies/types.js +0 -4
- package/dist/core/phone-auth/type-guards.js +0 -131
- package/dist/core/phone-auth/types.js +0 -32
- package/dist/core/phone-auth/ui/mobile-debug-console.js +2 -28
- package/dist/core/phone-auth/ui/modal.d.ts +33 -55
- package/dist/core/phone-auth/ui/modal.js +889 -422
- package/dist/core/phone-auth/validation-utils.js +2 -40
- package/dist/core/version.js +1 -2
- package/dist/esm/adapters/angular/index.js +0 -1
- package/dist/esm/adapters/angular/phone-auth.service.d.ts +0 -18
- package/dist/esm/adapters/angular/phone-auth.service.js +0 -26
- package/dist/esm/adapters/react/index.js +0 -3
- package/dist/esm/adapters/react/useClient.js +0 -1
- package/dist/esm/adapters/react/usePhoneAuth.js +1 -16
- package/dist/esm/adapters/vanilla/client.js +0 -1
- package/dist/esm/adapters/vanilla/index.js +0 -1
- package/dist/esm/adapters/vanilla/phone-auth.d.ts +0 -24
- package/dist/esm/adapters/vanilla/phone-auth.js +0 -31
- package/dist/esm/adapters/vue/index.js +0 -4
- package/dist/esm/adapters/vue/useClient.js +0 -5
- package/dist/esm/adapters/vue/usePhoneAuth.js +1 -20
- package/dist/esm/browser.js +0 -6
- package/dist/esm/core/client.d.ts +0 -10
- package/dist/esm/core/client.js +0 -12
- package/dist/esm/core/logger.d.ts +0 -53
- package/dist/esm/core/logger.js +1 -81
- package/dist/esm/core/phone-auth/api-types.d.ts +0 -315
- package/dist/esm/core/phone-auth/api-types.js +0 -83
- package/dist/esm/core/phone-auth/client.d.ts +0 -144
- package/dist/esm/core/phone-auth/client.js +27 -366
- package/dist/esm/core/phone-auth/error-utils.d.ts +0 -29
- package/dist/esm/core/phone-auth/error-utils.js +1 -83
- package/dist/esm/core/phone-auth/index.js +1 -3
- package/dist/esm/core/phone-auth/status-types.d.ts +0 -78
- package/dist/esm/core/phone-auth/status-types.js +0 -17
- package/dist/esm/core/phone-auth/strategies/desktop.d.ts +0 -63
- package/dist/esm/core/phone-auth/strategies/desktop.js +8 -126
- package/dist/esm/core/phone-auth/strategies/index.d.ts +0 -4
- package/dist/esm/core/phone-auth/strategies/index.js +0 -4
- package/dist/esm/core/phone-auth/strategies/link.d.ts +0 -48
- package/dist/esm/core/phone-auth/strategies/link.js +10 -88
- package/dist/esm/core/phone-auth/strategies/ts43.d.ts +0 -19
- package/dist/esm/core/phone-auth/strategies/ts43.js +2 -33
- package/dist/esm/core/phone-auth/strategies/types.d.ts +0 -13
- package/dist/esm/core/phone-auth/strategies/types.js +0 -4
- package/dist/esm/core/phone-auth/type-guards.d.ts +0 -128
- package/dist/esm/core/phone-auth/type-guards.js +0 -131
- package/dist/esm/core/phone-auth/types.d.ts +0 -108
- package/dist/esm/core/phone-auth/types.js +0 -32
- package/dist/esm/core/phone-auth/ui/mobile-debug-console.d.ts +0 -4
- package/dist/esm/core/phone-auth/ui/mobile-debug-console.js +2 -28
- package/dist/esm/core/phone-auth/ui/modal.d.ts +27 -68
- package/dist/esm/core/phone-auth/ui/modal.js +889 -422
- package/dist/esm/core/phone-auth/validation-utils.d.ts +0 -31
- package/dist/esm/core/phone-auth/validation-utils.js +2 -40
- package/dist/esm/core/types.d.ts +0 -35
- package/dist/esm/core/version.js +1 -2
- package/dist/esm/index.js +1 -9
- package/dist/index.js +0 -7
- package/package.json +1 -1
package/dist/esm/core/client.js
CHANGED
|
@@ -19,7 +19,6 @@ export class SDKClient {
|
|
|
19
19
|
'Content-Type': 'application/json',
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
|
-
// Initialize Phone Auth client
|
|
23
22
|
this.phoneAuth = new PhoneAuthClient({
|
|
24
23
|
endpoints: config.phoneAuthEndpoints ? {
|
|
25
24
|
prepare: config.phoneAuthEndpoints.prepareRequest,
|
|
@@ -27,7 +26,6 @@ export class SDKClient {
|
|
|
27
26
|
} : undefined,
|
|
28
27
|
debug: config.debug
|
|
29
28
|
});
|
|
30
|
-
// Add authentication interceptor
|
|
31
29
|
this.client.interceptors.request.use((config) => __awaiter(this, void 0, void 0, function* () {
|
|
32
30
|
if (this.token) {
|
|
33
31
|
config.headers.Authorization = `Bearer ${this.token}`;
|
|
@@ -35,22 +33,12 @@ export class SDKClient {
|
|
|
35
33
|
return config;
|
|
36
34
|
}));
|
|
37
35
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Set authentication token for API requests
|
|
40
|
-
*/
|
|
41
36
|
setToken(token) {
|
|
42
37
|
this.token = token;
|
|
43
38
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Clear authentication token
|
|
46
|
-
*/
|
|
47
39
|
clearToken() {
|
|
48
40
|
this.token = undefined;
|
|
49
41
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Make a GET request to the API
|
|
52
|
-
* Note: Requires baseURL to be set in the config
|
|
53
|
-
*/
|
|
54
42
|
get(path, options) {
|
|
55
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
44
|
if (!this.config.baseURL) {
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Industry-grade logging for Glide Web SDK
|
|
3
|
-
* Following best practices from Stripe, Auth0, Twilio, and AWS Amplify
|
|
4
|
-
*/
|
|
5
1
|
export declare enum LogLevel {
|
|
6
2
|
SILENT = 0,
|
|
7
3
|
ERROR = 1,
|
|
@@ -18,9 +14,6 @@ export interface Logger {
|
|
|
18
14
|
warn(message: string, fields?: LogFields): void;
|
|
19
15
|
error(message: string, fields?: LogFields): void;
|
|
20
16
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Default browser console logger with automatic data sanitization
|
|
23
|
-
*/
|
|
24
17
|
export declare class ConsoleLogger implements Logger {
|
|
25
18
|
private level;
|
|
26
19
|
private prefix;
|
|
@@ -31,28 +24,15 @@ export declare class ConsoleLogger implements Logger {
|
|
|
31
24
|
warn(message: string, fields?: LogFields): void;
|
|
32
25
|
error(message: string, fields?: LogFields): void;
|
|
33
26
|
private log;
|
|
34
|
-
/**
|
|
35
|
-
* Sanitize sensitive data from log fields
|
|
36
|
-
*/
|
|
37
27
|
private sanitizeFields;
|
|
38
|
-
/**
|
|
39
|
-
* Redact sensitive information based on field name and value patterns
|
|
40
|
-
*/
|
|
41
28
|
private sanitizeValue;
|
|
42
29
|
}
|
|
43
|
-
/**
|
|
44
|
-
* No-op logger for when logging is disabled
|
|
45
|
-
*/
|
|
46
30
|
export declare class NoopLogger implements Logger {
|
|
47
31
|
debug(message: string, fields?: LogFields): void;
|
|
48
32
|
info(message: string, fields?: LogFields): void;
|
|
49
33
|
warn(message: string, fields?: LogFields): void;
|
|
50
34
|
error(message: string, fields?: LogFields): void;
|
|
51
35
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Remote logger for sending logs to a backend service
|
|
54
|
-
* Useful for debugging production issues
|
|
55
|
-
*/
|
|
56
36
|
export declare class RemoteLogger implements Logger {
|
|
57
37
|
private endpoint;
|
|
58
38
|
private apiKey;
|
|
@@ -68,56 +48,23 @@ export declare class RemoteLogger implements Logger {
|
|
|
68
48
|
private log;
|
|
69
49
|
private flush;
|
|
70
50
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Parse log level from string
|
|
73
|
-
*/
|
|
74
51
|
export declare function parseLogLevel(level: string): LogLevel;
|
|
75
|
-
/**
|
|
76
|
-
* Get log level from browser environment
|
|
77
|
-
*/
|
|
78
52
|
export declare function getLogLevelFromEnv(): LogLevel;
|
|
79
|
-
/**
|
|
80
|
-
* Performance timer for measuring operation duration
|
|
81
|
-
*/
|
|
82
53
|
export declare class PerformanceTimer {
|
|
83
54
|
private startTime;
|
|
84
55
|
private marks;
|
|
85
56
|
private logger;
|
|
86
57
|
constructor(logger: Logger);
|
|
87
|
-
/**
|
|
88
|
-
* Mark a point in time
|
|
89
|
-
*/
|
|
90
58
|
mark(name: string): void;
|
|
91
|
-
/**
|
|
92
|
-
* Log elapsed time with optional fields
|
|
93
|
-
*/
|
|
94
59
|
logElapsed(message: string, fields?: LogFields): void;
|
|
95
|
-
/**
|
|
96
|
-
* Log time between marks
|
|
97
|
-
*/
|
|
98
60
|
logMarkDuration(fromMark: string, toMark: string, message: string, fields?: LogFields): void;
|
|
99
61
|
}
|
|
100
|
-
/**
|
|
101
|
-
* Generate a unique request ID for distributed tracing
|
|
102
|
-
*/
|
|
103
62
|
export declare function generateRequestId(): string;
|
|
104
|
-
/**
|
|
105
|
-
* Logger factory for creating loggers with consistent configuration
|
|
106
|
-
*/
|
|
107
63
|
export declare class LoggerFactory {
|
|
108
64
|
private static defaultLevel;
|
|
109
65
|
private static defaultLogger;
|
|
110
|
-
/**
|
|
111
|
-
* Set the default log level for all new loggers
|
|
112
|
-
*/
|
|
113
66
|
static setDefaultLevel(level: LogLevel): void;
|
|
114
|
-
/**
|
|
115
|
-
* Set a default logger instance to use
|
|
116
|
-
*/
|
|
117
67
|
static setDefaultLogger(logger: Logger): void;
|
|
118
|
-
/**
|
|
119
|
-
* Create a logger instance based on configuration
|
|
120
|
-
*/
|
|
121
68
|
static create(options?: {
|
|
122
69
|
level?: LogLevel;
|
|
123
70
|
prefix?: string;
|
package/dist/esm/core/logger.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Industry-grade logging for Glide Web SDK
|
|
3
|
-
* Following best practices from Stripe, Auth0, Twilio, and AWS Amplify
|
|
4
|
-
*/
|
|
5
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
6
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
7
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,9 +15,6 @@ export var LogLevel;
|
|
|
19
15
|
LogLevel[LogLevel["INFO"] = 3] = "INFO";
|
|
20
16
|
LogLevel[LogLevel["DEBUG"] = 4] = "DEBUG";
|
|
21
17
|
})(LogLevel || (LogLevel = {}));
|
|
22
|
-
/**
|
|
23
|
-
* Default browser console logger with automatic data sanitization
|
|
24
|
-
*/
|
|
25
18
|
export class ConsoleLogger {
|
|
26
19
|
constructor(level = LogLevel.SILENT, prefix = '[Glide]', enableGrouping = false) {
|
|
27
20
|
this.level = level;
|
|
@@ -51,9 +44,7 @@ export class ConsoleLogger {
|
|
|
51
44
|
log(level, message, fields) {
|
|
52
45
|
const timestamp = new Date().toISOString();
|
|
53
46
|
const sanitizedFields = fields ? this.sanitizeFields(fields) : {};
|
|
54
|
-
// Format the message
|
|
55
47
|
const formattedMessage = `${this.prefix} ${timestamp} [${level.toUpperCase()}] ${message}`;
|
|
56
|
-
// Use console grouping for better readability if enabled
|
|
57
48
|
if (this.enableGrouping && Object.keys(sanitizedFields).length > 0) {
|
|
58
49
|
console.groupCollapsed(formattedMessage);
|
|
59
50
|
Object.entries(sanitizedFields).forEach(([key, value]) => {
|
|
@@ -62,7 +53,6 @@ export class ConsoleLogger {
|
|
|
62
53
|
console.groupEnd();
|
|
63
54
|
}
|
|
64
55
|
else {
|
|
65
|
-
// Standard logging with or without fields
|
|
66
56
|
if (Object.keys(sanitizedFields).length > 0) {
|
|
67
57
|
console[level](formattedMessage, sanitizedFields);
|
|
68
58
|
}
|
|
@@ -71,9 +61,6 @@ export class ConsoleLogger {
|
|
|
71
61
|
}
|
|
72
62
|
}
|
|
73
63
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Sanitize sensitive data from log fields
|
|
76
|
-
*/
|
|
77
64
|
sanitizeFields(fields) {
|
|
78
65
|
const sanitized = {};
|
|
79
66
|
for (const [key, value] of Object.entries(fields)) {
|
|
@@ -81,11 +68,7 @@ export class ConsoleLogger {
|
|
|
81
68
|
}
|
|
82
69
|
return sanitized;
|
|
83
70
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Redact sensitive information based on field name and value patterns
|
|
86
|
-
*/
|
|
87
71
|
sanitizeValue(key, value) {
|
|
88
|
-
// List of sensitive field patterns
|
|
89
72
|
const sensitiveFields = [
|
|
90
73
|
'apikey', 'api_key', 'apiKey',
|
|
91
74
|
'token', 'accesstoken', 'access_token', 'accessToken',
|
|
@@ -95,7 +78,6 @@ export class ConsoleLogger {
|
|
|
95
78
|
'cookie', 'session',
|
|
96
79
|
];
|
|
97
80
|
const lowerKey = key.toLowerCase();
|
|
98
|
-
// Check if field name indicates sensitive data
|
|
99
81
|
for (const sensitive of sensitiveFields) {
|
|
100
82
|
if (lowerKey.includes(sensitive.toLowerCase())) {
|
|
101
83
|
if (typeof value === 'string' && value.length > 4) {
|
|
@@ -104,69 +86,52 @@ export class ConsoleLogger {
|
|
|
104
86
|
return '****[REDACTED]';
|
|
105
87
|
}
|
|
106
88
|
}
|
|
107
|
-
// Handle specific value patterns
|
|
108
89
|
if (typeof value === 'string') {
|
|
109
|
-
// Phone number pattern - show area code only
|
|
110
90
|
const phoneRegex = /^\+?[1-9]\d{6,14}$/;
|
|
111
91
|
if (phoneRegex.test(value)) {
|
|
112
92
|
return value.substring(0, 6) + '****';
|
|
113
93
|
}
|
|
114
|
-
// Email pattern - show domain only
|
|
115
94
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
116
95
|
if (emailRegex.test(value)) {
|
|
117
96
|
const [, domain] = value.split('@');
|
|
118
97
|
return '****@' + domain;
|
|
119
98
|
}
|
|
120
|
-
// URL with credentials
|
|
121
99
|
if (value.includes('://') && value.includes('@')) {
|
|
122
100
|
return value.replace(/\/\/([^:]+):([^@]+)@/, '//****:****@');
|
|
123
101
|
}
|
|
124
|
-
// JWT tokens
|
|
125
102
|
if (value.startsWith('eyJ') && value.split('.').length === 3) {
|
|
126
103
|
return value.substring(0, 10) + '****[JWT]';
|
|
127
104
|
}
|
|
128
|
-
// Credit card numbers
|
|
129
105
|
const creditCardRegex = /\b\d{13,19}\b/;
|
|
130
106
|
if (creditCardRegex.test(value)) {
|
|
131
107
|
return value.substring(0, 4) + '****' + value.substring(value.length - 4);
|
|
132
108
|
}
|
|
133
109
|
}
|
|
134
|
-
// Recursively sanitize objects
|
|
135
110
|
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
136
111
|
return this.sanitizeFields(value);
|
|
137
112
|
}
|
|
138
|
-
// Sanitize arrays
|
|
139
113
|
if (Array.isArray(value)) {
|
|
140
114
|
return value.map((item, index) => this.sanitizeValue(`${key}[${index}]`, item));
|
|
141
115
|
}
|
|
142
116
|
return value;
|
|
143
117
|
}
|
|
144
118
|
}
|
|
145
|
-
/**
|
|
146
|
-
* No-op logger for when logging is disabled
|
|
147
|
-
*/
|
|
148
119
|
export class NoopLogger {
|
|
149
120
|
debug(message, fields) { }
|
|
150
121
|
info(message, fields) { }
|
|
151
122
|
warn(message, fields) { }
|
|
152
123
|
error(message, fields) { }
|
|
153
124
|
}
|
|
154
|
-
/**
|
|
155
|
-
* Remote logger for sending logs to a backend service
|
|
156
|
-
* Useful for debugging production issues
|
|
157
|
-
*/
|
|
158
125
|
export class RemoteLogger {
|
|
159
126
|
constructor(endpoint, apiKey, fallbackLogger) {
|
|
160
127
|
this.buffer = [];
|
|
161
|
-
this.flushInterval = 5000;
|
|
128
|
+
this.flushInterval = 5000;
|
|
162
129
|
this.maxBufferSize = 100;
|
|
163
130
|
this.endpoint = endpoint;
|
|
164
131
|
this.apiKey = apiKey;
|
|
165
132
|
this.localLogger = fallbackLogger || new ConsoleLogger(LogLevel.ERROR);
|
|
166
|
-
// Set up automatic flushing
|
|
167
133
|
if (typeof window !== 'undefined') {
|
|
168
134
|
setInterval(() => this.flush(), this.flushInterval);
|
|
169
|
-
// Flush on page unload
|
|
170
135
|
window.addEventListener('beforeunload', () => this.flush());
|
|
171
136
|
}
|
|
172
137
|
}
|
|
@@ -192,9 +157,7 @@ export class RemoteLogger {
|
|
|
192
157
|
url: typeof window !== 'undefined' ? window.location.href : undefined,
|
|
193
158
|
};
|
|
194
159
|
this.buffer.push(logEntry);
|
|
195
|
-
// Also log locally for immediate feedback
|
|
196
160
|
this.localLogger[level](message, fields);
|
|
197
|
-
// Flush if buffer is full
|
|
198
161
|
if (this.buffer.length >= this.maxBufferSize) {
|
|
199
162
|
this.flush();
|
|
200
163
|
}
|
|
@@ -216,17 +179,11 @@ export class RemoteLogger {
|
|
|
216
179
|
});
|
|
217
180
|
}
|
|
218
181
|
catch (error) {
|
|
219
|
-
// Failed to send logs, log locally
|
|
220
182
|
this.localLogger.error('Failed to send logs to remote server', { error });
|
|
221
|
-
// Optionally, put logs back in buffer for retry
|
|
222
|
-
// this.buffer.unshift(...logs);
|
|
223
183
|
}
|
|
224
184
|
});
|
|
225
185
|
}
|
|
226
186
|
}
|
|
227
|
-
/**
|
|
228
|
-
* Parse log level from string
|
|
229
|
-
*/
|
|
230
187
|
export function parseLogLevel(level) {
|
|
231
188
|
switch (level.toLowerCase()) {
|
|
232
189
|
case 'debug':
|
|
@@ -246,11 +203,7 @@ export function parseLogLevel(level) {
|
|
|
246
203
|
return LogLevel.SILENT;
|
|
247
204
|
}
|
|
248
205
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Get log level from browser environment
|
|
251
|
-
*/
|
|
252
206
|
export function getLogLevelFromEnv() {
|
|
253
|
-
// Check localStorage
|
|
254
207
|
if (typeof localStorage !== 'undefined') {
|
|
255
208
|
const storedLevel = localStorage.getItem('GLIDE_LOG_LEVEL');
|
|
256
209
|
if (storedLevel) {
|
|
@@ -261,7 +214,6 @@ export function getLogLevelFromEnv() {
|
|
|
261
214
|
return LogLevel.DEBUG;
|
|
262
215
|
}
|
|
263
216
|
}
|
|
264
|
-
// Check URL parameters
|
|
265
217
|
if (typeof window !== 'undefined' && window.location) {
|
|
266
218
|
const params = new URLSearchParams(window.location.search);
|
|
267
219
|
const urlLogLevel = params.get('glide_log_level');
|
|
@@ -274,31 +226,19 @@ export function getLogLevelFromEnv() {
|
|
|
274
226
|
}
|
|
275
227
|
return LogLevel.SILENT;
|
|
276
228
|
}
|
|
277
|
-
/**
|
|
278
|
-
* Performance timer for measuring operation duration
|
|
279
|
-
*/
|
|
280
229
|
export class PerformanceTimer {
|
|
281
230
|
constructor(logger) {
|
|
282
231
|
this.marks = new Map();
|
|
283
232
|
this.startTime = performance.now();
|
|
284
233
|
this.logger = logger;
|
|
285
234
|
}
|
|
286
|
-
/**
|
|
287
|
-
* Mark a point in time
|
|
288
|
-
*/
|
|
289
235
|
mark(name) {
|
|
290
236
|
this.marks.set(name, performance.now());
|
|
291
237
|
}
|
|
292
|
-
/**
|
|
293
|
-
* Log elapsed time with optional fields
|
|
294
|
-
*/
|
|
295
238
|
logElapsed(message, fields) {
|
|
296
239
|
const elapsed = performance.now() - this.startTime;
|
|
297
240
|
this.logger.debug(message, Object.assign(Object.assign({}, fields), { elapsedMs: elapsed, elapsed: `${elapsed.toFixed(2)}ms` }));
|
|
298
241
|
}
|
|
299
|
-
/**
|
|
300
|
-
* Log time between marks
|
|
301
|
-
*/
|
|
302
242
|
logMarkDuration(fromMark, toMark, message, fields) {
|
|
303
243
|
const from = this.marks.get(fromMark);
|
|
304
244
|
const to = this.marks.get(toMark);
|
|
@@ -309,49 +249,29 @@ export class PerformanceTimer {
|
|
|
309
249
|
}
|
|
310
250
|
}
|
|
311
251
|
}
|
|
312
|
-
/**
|
|
313
|
-
* Generate a unique request ID for distributed tracing
|
|
314
|
-
*/
|
|
315
252
|
export function generateRequestId() {
|
|
316
253
|
return `req_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
317
254
|
}
|
|
318
|
-
/**
|
|
319
|
-
* Logger factory for creating loggers with consistent configuration
|
|
320
|
-
*/
|
|
321
255
|
export class LoggerFactory {
|
|
322
|
-
/**
|
|
323
|
-
* Set the default log level for all new loggers
|
|
324
|
-
*/
|
|
325
256
|
static setDefaultLevel(level) {
|
|
326
257
|
this.defaultLevel = level;
|
|
327
258
|
}
|
|
328
|
-
/**
|
|
329
|
-
* Set a default logger instance to use
|
|
330
|
-
*/
|
|
331
259
|
static setDefaultLogger(logger) {
|
|
332
260
|
this.defaultLogger = logger;
|
|
333
261
|
}
|
|
334
|
-
/**
|
|
335
|
-
* Create a logger instance based on configuration
|
|
336
|
-
*/
|
|
337
262
|
static create(options) {
|
|
338
263
|
var _a, _b;
|
|
339
|
-
// Use custom logger if provided
|
|
340
264
|
if (options === null || options === void 0 ? void 0 : options.custom) {
|
|
341
265
|
return options.custom;
|
|
342
266
|
}
|
|
343
|
-
// Use default logger if set
|
|
344
267
|
if (this.defaultLogger) {
|
|
345
268
|
return this.defaultLogger;
|
|
346
269
|
}
|
|
347
|
-
// Determine log level
|
|
348
270
|
const level = (_b = (_a = options === null || options === void 0 ? void 0 : options.level) !== null && _a !== void 0 ? _a : getLogLevelFromEnv()) !== null && _b !== void 0 ? _b : this.defaultLevel;
|
|
349
|
-
// Create remote logger if configured
|
|
350
271
|
if (options === null || options === void 0 ? void 0 : options.remote) {
|
|
351
272
|
const fallbackLogger = new ConsoleLogger(level, options === null || options === void 0 ? void 0 : options.prefix);
|
|
352
273
|
return new RemoteLogger(options.remote.endpoint, options.remote.apiKey, fallbackLogger);
|
|
353
274
|
}
|
|
354
|
-
// Create console logger
|
|
355
275
|
return new ConsoleLogger(level, options === null || options === void 0 ? void 0 : options.prefix);
|
|
356
276
|
}
|
|
357
277
|
}
|