@bernierllc/logging-utils 0.1.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.
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.AuditLogAnalyzer = exports.LogAnalyzer = void 0;
11
+ /**
12
+ * Log analysis utilities for parsing and analyzing log data
13
+ */
14
+ class LogAnalyzer {
15
+ constructor() {
16
+ this.logs = [];
17
+ }
18
+ /**
19
+ * Add a log entry to the analyzer
20
+ */
21
+ addLog(log) {
22
+ this.logs.push(log);
23
+ }
24
+ /**
25
+ * Add multiple log entries
26
+ */
27
+ addLogs(logs) {
28
+ this.logs.push(...logs);
29
+ }
30
+ /**
31
+ * Clear all logs
32
+ */
33
+ clear() {
34
+ this.logs = [];
35
+ }
36
+ /**
37
+ * Get logs by level
38
+ */
39
+ getLogsByLevel(level) {
40
+ return this.logs.filter(log => log.level === level);
41
+ }
42
+ /**
43
+ * Get logs by time range
44
+ */
45
+ getLogsByTimeRange(startTime, endTime) {
46
+ return this.logs.filter(log => {
47
+ const logTime = new Date(log.timestamp).getTime();
48
+ const start = new Date(startTime).getTime();
49
+ const end = new Date(endTime).getTime();
50
+ return logTime >= start && logTime <= end;
51
+ });
52
+ }
53
+ /**
54
+ * Get logs containing specific text
55
+ */
56
+ getLogsByText(searchText) {
57
+ const lowerSearch = searchText.toLowerCase();
58
+ return this.logs.filter(log => log.message.toLowerCase().includes(lowerSearch) ||
59
+ JSON.stringify(log.metadata).toLowerCase().includes(lowerSearch));
60
+ }
61
+ /**
62
+ * Get error frequency analysis
63
+ */
64
+ getErrorAnalysis() {
65
+ const errors = this.getLogsByLevel('error');
66
+ const errorMessages = {};
67
+ errors.forEach(error => {
68
+ const message = error.message;
69
+ errorMessages[message] = (errorMessages[message] || 0) + 1;
70
+ });
71
+ return errorMessages;
72
+ }
73
+ /**
74
+ * Get performance statistics
75
+ */
76
+ getPerformanceStats() {
77
+ const totalLogs = this.logs.length;
78
+ const errors = this.getLogsByLevel('error').length;
79
+ const warnings = this.getLogsByLevel('warn').length;
80
+ const info = this.getLogsByLevel('info').length;
81
+ const debug = this.getLogsByLevel('debug').length;
82
+ // Calculate average logs per hour
83
+ let averageLogsPerHour = 0;
84
+ if (this.logs.length > 1) {
85
+ const firstLogEntry = this.logs[0];
86
+ const lastLogEntry = this.logs[this.logs.length - 1];
87
+ if (firstLogEntry && lastLogEntry) {
88
+ const firstLog = new Date(firstLogEntry.timestamp);
89
+ const lastLog = new Date(lastLogEntry.timestamp);
90
+ const hoursDiff = (lastLog.getTime() - firstLog.getTime()) / (1000 * 60 * 60);
91
+ averageLogsPerHour = hoursDiff > 0 ? totalLogs / hoursDiff : totalLogs;
92
+ }
93
+ }
94
+ return {
95
+ totalLogs,
96
+ errors,
97
+ warnings,
98
+ info,
99
+ debug,
100
+ averageLogsPerHour
101
+ };
102
+ }
103
+ /**
104
+ * Get unique users from logs
105
+ */
106
+ getUniqueUsers() {
107
+ const users = new Set();
108
+ this.logs.forEach(log => {
109
+ if (log.userId) {
110
+ users.add(log.userId);
111
+ }
112
+ });
113
+ return Array.from(users);
114
+ }
115
+ /**
116
+ * Get unique request IDs from logs
117
+ */
118
+ getUniqueRequestIds() {
119
+ const requestIds = new Set();
120
+ this.logs.forEach(log => {
121
+ if (log.requestId) {
122
+ requestIds.add(log.requestId);
123
+ }
124
+ });
125
+ return Array.from(requestIds);
126
+ }
127
+ }
128
+ exports.LogAnalyzer = LogAnalyzer;
129
+ /**
130
+ * Audit log analyzer for security and compliance analysis
131
+ */
132
+ class AuditLogAnalyzer {
133
+ constructor() {
134
+ this.auditLogs = [];
135
+ }
136
+ /**
137
+ * Add an audit log entry
138
+ */
139
+ addAuditLog(log) {
140
+ this.auditLogs.push(log);
141
+ }
142
+ /**
143
+ * Get audit logs by actor
144
+ */
145
+ getAuditLogsByActor(actorId) {
146
+ return this.auditLogs.filter(log => log.actorId === actorId);
147
+ }
148
+ /**
149
+ * Get audit logs by action
150
+ */
151
+ getAuditLogsByAction(action) {
152
+ return this.auditLogs.filter(log => log.action === action);
153
+ }
154
+ /**
155
+ * Get audit logs by target
156
+ */
157
+ getAuditLogsByTarget(target) {
158
+ return this.auditLogs.filter(log => log.target === target);
159
+ }
160
+ /**
161
+ * Get suspicious activity (high frequency actions)
162
+ */
163
+ getSuspiciousActivity(threshold = 10) {
164
+ const actionCounts = {};
165
+ this.auditLogs.forEach(log => {
166
+ const key = `${log.actorId}:${log.action}`;
167
+ actionCounts[key] = (actionCounts[key] || 0) + 1;
168
+ });
169
+ // Filter by threshold
170
+ const suspicious = {};
171
+ Object.entries(actionCounts).forEach(([key, count]) => {
172
+ if (count >= threshold) {
173
+ suspicious[key] = count;
174
+ }
175
+ });
176
+ return suspicious;
177
+ }
178
+ /**
179
+ * Get user activity summary
180
+ */
181
+ getUserActivitySummary() {
182
+ const userActivity = {};
183
+ this.auditLogs.forEach(log => {
184
+ if (!userActivity[log.actorId]) {
185
+ userActivity[log.actorId] = { actions: new Set(), count: 0 };
186
+ }
187
+ const activity = userActivity[log.actorId];
188
+ if (activity) {
189
+ activity.actions.add(log.action);
190
+ activity.count++;
191
+ }
192
+ });
193
+ // Convert Set to Array for JSON serialization
194
+ const result = {};
195
+ Object.entries(userActivity).forEach(([userId, data]) => {
196
+ result[userId] = {
197
+ actions: Array.from(data.actions),
198
+ count: data.count
199
+ };
200
+ });
201
+ return result;
202
+ }
203
+ }
204
+ exports.AuditLogAnalyzer = AuditLogAnalyzer;
@@ -0,0 +1,55 @@
1
+ import { LogEntry } from './types';
2
+ /**
3
+ * Log format conversion utilities
4
+ */
5
+ export declare class LogFormatter {
6
+ /**
7
+ * Convert log entry to JSON string
8
+ */
9
+ static toJSON(log: LogEntry): string;
10
+ /**
11
+ * Convert log entry to simple text format
12
+ */
13
+ static toText(log: LogEntry): string;
14
+ /**
15
+ * Convert log entry to CSV format
16
+ */
17
+ static toCSV(log: LogEntry): string;
18
+ /**
19
+ * Convert log entry to syslog format
20
+ */
21
+ static toSyslog(log: LogEntry): string;
22
+ /**
23
+ * Convert log entry to logfmt format
24
+ */
25
+ static toLogfmt(log: LogEntry): string;
26
+ /**
27
+ * Get syslog severity for log level
28
+ */
29
+ private static getSyslogSeverity;
30
+ /**
31
+ * Convert multiple logs to a specific format
32
+ */
33
+ static formatMultiple(logs: LogEntry[], format: 'json' | 'text' | 'csv' | 'syslog' | 'logfmt'): string;
34
+ }
35
+ /**
36
+ * Log parser for converting between formats
37
+ */
38
+ export declare class LogParser {
39
+ /**
40
+ * Parse JSON log entry
41
+ */
42
+ static fromJSON(json: string): LogEntry;
43
+ /**
44
+ * Parse text log entry (basic implementation)
45
+ */
46
+ static fromText(text: string): LogEntry;
47
+ /**
48
+ * Parse CSV log entry
49
+ */
50
+ static fromCSV(csv: string): LogEntry;
51
+ /**
52
+ * Parse multiple logs from a specific format
53
+ */
54
+ static parseMultiple(content: string, format: 'json' | 'csv' | 'text'): LogEntry[];
55
+ }
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.LogParser = exports.LogFormatter = void 0;
11
+ /**
12
+ * Log format conversion utilities
13
+ */
14
+ class LogFormatter {
15
+ /**
16
+ * Convert log entry to JSON string
17
+ */
18
+ static toJSON(log) {
19
+ return JSON.stringify(log, null, 2);
20
+ }
21
+ /**
22
+ * Convert log entry to simple text format
23
+ */
24
+ static toText(log) {
25
+ const timestamp = new Date(log.timestamp).toISOString();
26
+ const metadata = log.metadata ? ` ${JSON.stringify(log.metadata)}` : '';
27
+ return `[${timestamp}] ${log.level.toUpperCase()}: ${log.message}${metadata}`;
28
+ }
29
+ /**
30
+ * Convert log entry to CSV format
31
+ */
32
+ static toCSV(log) {
33
+ const timestamp = new Date(log.timestamp).toISOString();
34
+ const metadata = log.metadata ? JSON.stringify(log.metadata) : '';
35
+ const context = log.context || '';
36
+ const requestId = log.requestId || '';
37
+ const userId = log.userId || '';
38
+ return `"${timestamp}","${log.level}","${log.message}","${context}","${requestId}","${userId}","${metadata}"`;
39
+ }
40
+ /**
41
+ * Convert log entry to syslog format
42
+ */
43
+ static toSyslog(log) {
44
+ const timestamp = new Date(log.timestamp).toISOString();
45
+ const facility = 1; // user facility
46
+ const severity = this.getSyslogSeverity(log.level);
47
+ const priority = facility * 8 + severity;
48
+ return `<${priority}>${timestamp} ${log.message}`;
49
+ }
50
+ /**
51
+ * Convert log entry to logfmt format
52
+ */
53
+ static toLogfmt(log) {
54
+ const timestamp = new Date(log.timestamp).toISOString();
55
+ let result = `timestamp=${timestamp} level=${log.level} message="${log.message}"`;
56
+ if (log.context) {
57
+ result += ` context=${log.context}`;
58
+ }
59
+ if (log.requestId) {
60
+ result += ` request_id=${log.requestId}`;
61
+ }
62
+ if (log.userId) {
63
+ result += ` user_id=${log.userId}`;
64
+ }
65
+ if (log.metadata) {
66
+ Object.entries(log.metadata).forEach(([key, value]) => {
67
+ result += ` ${key}=${JSON.stringify(value)}`;
68
+ });
69
+ }
70
+ return result;
71
+ }
72
+ /**
73
+ * Get syslog severity for log level
74
+ */
75
+ static getSyslogSeverity(level) {
76
+ switch (level) {
77
+ case 'error': return 3; // Error
78
+ case 'warn': return 4; // Warning
79
+ case 'info': return 6; // Informational
80
+ case 'debug': return 7; // Debug
81
+ default: return 6;
82
+ }
83
+ }
84
+ /**
85
+ * Convert multiple logs to a specific format
86
+ */
87
+ static formatMultiple(logs, format) {
88
+ switch (format) {
89
+ case 'json':
90
+ return JSON.stringify(logs, null, 2);
91
+ case 'csv':
92
+ const headers = 'timestamp,level,message,context,requestId,userId,metadata';
93
+ const rows = logs.map(log => this.toCSV(log));
94
+ return `${headers}\n${rows.join('\n')}`;
95
+ case 'text':
96
+ return logs.map(log => this.toText(log)).join('\n');
97
+ case 'syslog':
98
+ return logs.map(log => this.toSyslog(log)).join('\n');
99
+ case 'logfmt':
100
+ return logs.map(log => this.toLogfmt(log)).join('\n');
101
+ default:
102
+ throw new Error(`Unsupported format: ${format}`);
103
+ }
104
+ }
105
+ }
106
+ exports.LogFormatter = LogFormatter;
107
+ /**
108
+ * Log parser for converting between formats
109
+ */
110
+ class LogParser {
111
+ /**
112
+ * Parse JSON log entry
113
+ */
114
+ static fromJSON(json) {
115
+ const parsed = JSON.parse(json);
116
+ // Validate required fields
117
+ if (!parsed.level || !parsed.message || !parsed.timestamp) {
118
+ throw new Error('Invalid log entry: missing required fields');
119
+ }
120
+ return parsed;
121
+ }
122
+ /**
123
+ * Parse text log entry (basic implementation)
124
+ */
125
+ static fromText(text) {
126
+ // This is a basic implementation - in practice you'd want a more robust parser
127
+ const match = text.match(/\[([^\]]+)\] (\w+): (.+)/);
128
+ if (!match) {
129
+ throw new Error('Invalid text log format');
130
+ }
131
+ const [, timestamp, level, message] = match;
132
+ if (!level || !message || !timestamp) {
133
+ throw new Error('Invalid text log format: missing level, message, or timestamp');
134
+ }
135
+ return {
136
+ level: level.toLowerCase(),
137
+ message: message.trim(),
138
+ timestamp: timestamp,
139
+ metadata: {}
140
+ };
141
+ }
142
+ /**
143
+ * Parse CSV log entry
144
+ */
145
+ static fromCSV(csv) {
146
+ const columns = csv.split(',').map(col => col.replace(/^"|"$/g, ''));
147
+ if (columns.length < 3) {
148
+ throw new Error('Invalid CSV log format');
149
+ }
150
+ const [timestamp, level, message, context, requestId, userId, metadataStr] = columns;
151
+ if (!level || !message || !timestamp) {
152
+ throw new Error('Invalid CSV log format: missing level, message, or timestamp');
153
+ }
154
+ let metadata = {};
155
+ if (metadataStr && metadataStr !== '') {
156
+ try {
157
+ metadata = JSON.parse(metadataStr);
158
+ }
159
+ catch {
160
+ // Ignore metadata parsing errors
161
+ }
162
+ }
163
+ return {
164
+ level: level.toLowerCase(),
165
+ message,
166
+ timestamp,
167
+ ...(context && { context }),
168
+ ...(requestId && { requestId }),
169
+ ...(userId && { userId }),
170
+ metadata
171
+ };
172
+ }
173
+ /**
174
+ * Parse multiple logs from a specific format
175
+ */
176
+ static parseMultiple(content, format) {
177
+ switch (format) {
178
+ case 'json':
179
+ const parsed = JSON.parse(content);
180
+ return Array.isArray(parsed) ? parsed : [parsed];
181
+ case 'csv':
182
+ const lines = content.split('\n').filter(line => line.trim());
183
+ const headers = lines[0];
184
+ const dataLines = lines.slice(1);
185
+ return dataLines.map(line => this.fromCSV(line));
186
+ case 'text':
187
+ return content.split('\n')
188
+ .filter(line => line.trim())
189
+ .map(line => this.fromText(line));
190
+ default:
191
+ throw new Error(`Unsupported format: ${format}`);
192
+ }
193
+ }
194
+ }
195
+ exports.LogParser = LogParser;
@@ -0,0 +1,4 @@
1
+ export * from './performance';
2
+ export * from './analysis';
3
+ export * from './aggregation';
4
+ export * from './formatters';
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ // Export all utility functions
25
+ __exportStar(require("./performance"), exports);
26
+ __exportStar(require("./analysis"), exports);
27
+ __exportStar(require("./aggregation"), exports);
28
+ __exportStar(require("./formatters"), exports);
@@ -0,0 +1,67 @@
1
+ import { LogEntry, PerformanceMetrics } from './types';
2
+ /**
3
+ * Performance logger for tracking timing and metrics
4
+ */
5
+ export declare class PerformanceLogger {
6
+ private timers;
7
+ private metrics;
8
+ private counters;
9
+ /**
10
+ * Start a timer for a named operation
11
+ */
12
+ startTimer(name: string): void;
13
+ /**
14
+ * End a timer and log the duration
15
+ */
16
+ endTimer(name: string, metadata?: Record<string, unknown>): number;
17
+ /**
18
+ * Increment a counter
19
+ */
20
+ incrementCounter(name: string, value?: number): void;
21
+ /**
22
+ * Get current metrics for a named operation
23
+ */
24
+ getMetrics(name: string): PerformanceMetrics | undefined;
25
+ /**
26
+ * Get all metrics
27
+ */
28
+ getAllMetrics(): Map<string, PerformanceMetrics>;
29
+ /**
30
+ * Get counter value
31
+ */
32
+ getCounter(name: string): number;
33
+ /**
34
+ * Get all counters
35
+ */
36
+ getAllCounters(): Map<string, number>;
37
+ /**
38
+ * Reset all timers, metrics, and counters
39
+ */
40
+ reset(): void;
41
+ /**
42
+ * Create a log entry with performance data
43
+ */
44
+ createPerformanceLog(name: string, level?: 'info' | 'warn' | 'error'): LogEntry;
45
+ }
46
+ /**
47
+ * Memory usage tracker
48
+ */
49
+ export declare class MemoryTracker {
50
+ private snapshots;
51
+ /**
52
+ * Take a memory snapshot
53
+ */
54
+ takeSnapshot(name: string): NodeJS.MemoryUsage;
55
+ /**
56
+ * Get memory snapshot
57
+ */
58
+ getSnapshot(name: string): NodeJS.MemoryUsage | undefined;
59
+ /**
60
+ * Compare two snapshots
61
+ */
62
+ compareSnapshots(name1: string, name2: string): Record<string, number>;
63
+ /**
64
+ * Get memory usage as percentage
65
+ */
66
+ getMemoryUsagePercentage(): number;
67
+ }
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (c) 2025 Bernier LLC
4
+
5
+ This file is licensed to the client under a limited-use license.
6
+ The client may use and modify this code *only within the scope of the project it was delivered for*.
7
+ Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MemoryTracker = exports.PerformanceLogger = void 0;
11
+ /**
12
+ * Performance logger for tracking timing and metrics
13
+ */
14
+ class PerformanceLogger {
15
+ constructor() {
16
+ this.timers = new Map();
17
+ this.metrics = new Map();
18
+ this.counters = new Map();
19
+ }
20
+ /**
21
+ * Start a timer for a named operation
22
+ */
23
+ startTimer(name) {
24
+ this.timers.set(name, Date.now());
25
+ }
26
+ /**
27
+ * End a timer and log the duration
28
+ */
29
+ endTimer(name, metadata) {
30
+ const startTime = this.timers.get(name);
31
+ if (!startTime) {
32
+ throw new Error(`Timer '${name}' was not started`);
33
+ }
34
+ const duration = Date.now() - startTime;
35
+ this.timers.delete(name);
36
+ // Update metrics
37
+ const existingMetrics = this.metrics.get(name) || { duration: 0, requestCount: 0 };
38
+ this.metrics.set(name, {
39
+ ...existingMetrics,
40
+ duration: duration,
41
+ requestCount: (existingMetrics.requestCount || 0) + 1
42
+ });
43
+ return duration;
44
+ }
45
+ /**
46
+ * Increment a counter
47
+ */
48
+ incrementCounter(name, value = 1) {
49
+ const current = this.counters.get(name) || 0;
50
+ this.counters.set(name, current + value);
51
+ }
52
+ /**
53
+ * Get current metrics for a named operation
54
+ */
55
+ getMetrics(name) {
56
+ return this.metrics.get(name);
57
+ }
58
+ /**
59
+ * Get all metrics
60
+ */
61
+ getAllMetrics() {
62
+ return new Map(this.metrics);
63
+ }
64
+ /**
65
+ * Get counter value
66
+ */
67
+ getCounter(name) {
68
+ return this.counters.get(name) || 0;
69
+ }
70
+ /**
71
+ * Get all counters
72
+ */
73
+ getAllCounters() {
74
+ return new Map(this.counters);
75
+ }
76
+ /**
77
+ * Reset all timers, metrics, and counters
78
+ */
79
+ reset() {
80
+ this.timers.clear();
81
+ this.metrics.clear();
82
+ this.counters.clear();
83
+ }
84
+ /**
85
+ * Create a log entry with performance data
86
+ */
87
+ createPerformanceLog(name, level = 'info') {
88
+ const metrics = this.getMetrics(name);
89
+ const counter = this.getCounter(name);
90
+ return {
91
+ level,
92
+ message: `Performance metrics for ${name}`,
93
+ timestamp: new Date().toISOString(),
94
+ metadata: {
95
+ operation: name,
96
+ metrics,
97
+ counter,
98
+ activeTimers: Array.from(this.timers.keys())
99
+ }
100
+ };
101
+ }
102
+ }
103
+ exports.PerformanceLogger = PerformanceLogger;
104
+ /**
105
+ * Memory usage tracker
106
+ */
107
+ class MemoryTracker {
108
+ constructor() {
109
+ this.snapshots = new Map();
110
+ }
111
+ /**
112
+ * Take a memory snapshot
113
+ */
114
+ takeSnapshot(name) {
115
+ const usage = process.memoryUsage();
116
+ this.snapshots.set(name, usage);
117
+ return usage;
118
+ }
119
+ /**
120
+ * Get memory snapshot
121
+ */
122
+ getSnapshot(name) {
123
+ return this.snapshots.get(name);
124
+ }
125
+ /**
126
+ * Compare two snapshots
127
+ */
128
+ compareSnapshots(name1, name2) {
129
+ const snap1 = this.getSnapshot(name1);
130
+ const snap2 = this.getSnapshot(name2);
131
+ if (!snap1 || !snap2) {
132
+ throw new Error('One or both snapshots not found');
133
+ }
134
+ return {
135
+ rssDiff: snap2.rss - snap1.rss,
136
+ heapTotalDiff: snap2.heapTotal - snap1.heapTotal,
137
+ heapUsedDiff: snap2.heapUsed - snap1.heapUsed,
138
+ externalDiff: snap2.external - snap1.external
139
+ };
140
+ }
141
+ /**
142
+ * Get memory usage as percentage
143
+ */
144
+ getMemoryUsagePercentage() {
145
+ const usage = process.memoryUsage();
146
+ return (usage.heapUsed / usage.heapTotal) * 100;
147
+ }
148
+ }
149
+ exports.MemoryTracker = MemoryTracker;