axon-logger 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/axon.browser.js +2 -0
- package/dist/axon.browser.js.map +1 -0
- package/dist/cli/axon-cli.d.ts +7 -0
- package/dist/cli/axon-cli.d.ts.map +1 -0
- package/dist/cli/axon-cli.js +179 -0
- package/dist/cli/axon-cli.js.map +1 -0
- package/dist/extractor/LogExtractor.d.ts +64 -0
- package/dist/extractor/LogExtractor.d.ts.map +1 -0
- package/dist/extractor/LogExtractor.js +237 -0
- package/dist/extractor/LogExtractor.js.map +1 -0
- package/dist/extractor/index.d.ts +2 -0
- package/dist/extractor/index.d.ts.map +1 -0
- package/dist/extractor/index.js +6 -0
- package/dist/extractor/index.js.map +1 -0
- package/dist/file-manager/BrowserFileManager.d.ts +102 -0
- package/dist/file-manager/BrowserFileManager.d.ts.map +1 -0
- package/dist/file-manager/BrowserFileManager.js +281 -0
- package/dist/file-manager/BrowserFileManager.js.map +1 -0
- package/dist/file-manager/FileManager.d.ts +103 -0
- package/dist/file-manager/FileManager.d.ts.map +1 -0
- package/dist/file-manager/FileManager.js +331 -0
- package/dist/file-manager/FileManager.js.map +1 -0
- package/dist/file-manager/index.d.ts +7 -0
- package/dist/file-manager/index.d.ts.map +1 -0
- package/dist/file-manager/index.js +11 -0
- package/dist/file-manager/index.js.map +1 -0
- package/dist/file-manager/types.d.ts +37 -0
- package/dist/file-manager/types.d.ts.map +1 -0
- package/dist/file-manager/types.js +6 -0
- package/dist/file-manager/types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/ConfigLoader.d.ts +27 -0
- package/dist/logger/ConfigLoader.d.ts.map +1 -0
- package/dist/logger/ConfigLoader.js +210 -0
- package/dist/logger/ConfigLoader.js.map +1 -0
- package/dist/logger/Logger.d.ts +142 -0
- package/dist/logger/Logger.d.ts.map +1 -0
- package/dist/logger/Logger.js +511 -0
- package/dist/logger/Logger.js.map +1 -0
- package/dist/logger/index.d.ts +7 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +17 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/types.d.ts +107 -0
- package/dist/logger/types.d.ts.map +1 -0
- package/dist/logger/types.js +57 -0
- package/dist/logger/types.js.map +1 -0
- package/dist/parser/StreamingParser.d.ts +21 -0
- package/dist/parser/StreamingParser.d.ts.map +1 -0
- package/dist/parser/StreamingParser.js +70 -0
- package/dist/parser/StreamingParser.js.map +1 -0
- package/dist/parser/TOONParser.d.ts +113 -0
- package/dist/parser/TOONParser.d.ts.map +1 -0
- package/dist/parser/TOONParser.js +386 -0
- package/dist/parser/TOONParser.js.map +1 -0
- package/dist/parser/index.d.ts +8 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +13 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/serializer/TOONSerializer.d.ts +232 -0
- package/dist/serializer/TOONSerializer.d.ts.map +1 -0
- package/dist/serializer/TOONSerializer.js +497 -0
- package/dist/serializer/TOONSerializer.js.map +1 -0
- package/dist/serializer/index.d.ts +7 -0
- package/dist/serializer/index.d.ts.map +1 -0
- package/dist/serializer/index.js +11 -0
- package/dist/serializer/index.js.map +1 -0
- package/dist/utils/TokenCounter.d.ts +31 -0
- package/dist/utils/TokenCounter.d.ts.map +1 -0
- package/dist/utils/TokenCounter.js +44 -0
- package/dist/utils/TokenCounter.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/index.js.map +1 -0
- package/docs/API.md +315 -0
- package/package.json +49 -0
- package/tsconfig.json +24 -0
package/README.md
ADDED
|
Binary file
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AXON=t():e.AXON=t()}(this,()=>(()=>{"use strict";var e={};return e.default})());
|
|
2
|
+
//# sourceMappingURL=axon.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axon.browser.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAc,KAAID,IAElBD,EAAW,KAAIC,GAChB,CATD,CASGK,KAAM,I","sources":["webpack://AXON/webpack/universalModuleDefinition"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"AXON\"] = factory();\n\telse\n\t\troot[\"AXON\"] = factory();\n})(this, () => {\nreturn "],"names":["root","factory","exports","module","define","amd","this"],"sourceRoot":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axon-cli.d.ts","sourceRoot":"","sources":["../../src/cli/axon-cli.ts"],"names":[],"mappings":";AAEA;;;GAGG"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* AXON CLI Tool
|
|
5
|
+
* Command-line interface for log extraction, counting, and export
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
const commander_1 = require("commander");
|
|
42
|
+
const LogExtractor_1 = require("../extractor/LogExtractor");
|
|
43
|
+
const types_1 = require("../logger/types");
|
|
44
|
+
const TokenCounter_1 = require("../utils/TokenCounter");
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const program = new commander_1.Command();
|
|
47
|
+
program
|
|
48
|
+
.name('axon')
|
|
49
|
+
.description('AXON logging framework CLI - Extract, count, and export logs')
|
|
50
|
+
.version('1.0.0');
|
|
51
|
+
// Extract command
|
|
52
|
+
program
|
|
53
|
+
.command('extract')
|
|
54
|
+
.description('Extract logs from a file based on filters')
|
|
55
|
+
.argument('<file>', 'Path to log file')
|
|
56
|
+
.option('-s, --section <label>', 'Extract section by marker label')
|
|
57
|
+
.option('-e, --end-section <label>', 'End section marker label')
|
|
58
|
+
.option('-t, --time-range <start,end>', 'Extract by time range (ISO 8601 timestamps)')
|
|
59
|
+
.option('-l, --level <level>', 'Extract by minimum log level (DEBUG, INFO, WARN, ERROR, FATAL)')
|
|
60
|
+
.option('-o, --output <file>', 'Output file (default: stdout)')
|
|
61
|
+
.action(async (file, options) => {
|
|
62
|
+
try {
|
|
63
|
+
const extractor = new LogExtractor_1.LogExtractor(file);
|
|
64
|
+
let result;
|
|
65
|
+
if (options.section) {
|
|
66
|
+
result = extractor.extractSection(options.section, options.endSection);
|
|
67
|
+
}
|
|
68
|
+
else if (options.timeRange) {
|
|
69
|
+
const [start, end] = options.timeRange.split(',');
|
|
70
|
+
result = extractor.extractTimeRange(new Date(start), new Date(end));
|
|
71
|
+
}
|
|
72
|
+
else if (options.level) {
|
|
73
|
+
const levelMap = {
|
|
74
|
+
'DEBUG': types_1.LogLevel.DEBUG,
|
|
75
|
+
'INFO': types_1.LogLevel.INFO,
|
|
76
|
+
'WARN': types_1.LogLevel.WARN,
|
|
77
|
+
'ERROR': types_1.LogLevel.ERROR,
|
|
78
|
+
'FATAL': types_1.LogLevel.FATAL
|
|
79
|
+
};
|
|
80
|
+
const level = levelMap[options.level.toUpperCase()];
|
|
81
|
+
if (level === undefined) {
|
|
82
|
+
console.error(`Invalid log level: ${options.level}`);
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
result = extractor.extractByLevel(level);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
console.error('Please specify a filter: --section, --time-range, or --level');
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
if (options.output) {
|
|
92
|
+
await fs.promises.writeFile(options.output, result, 'utf8');
|
|
93
|
+
console.log(`Extracted logs written to ${options.output}`);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
console.log(result);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error(`Error: ${error.message}`);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
// Count command
|
|
105
|
+
program
|
|
106
|
+
.command('count')
|
|
107
|
+
.description('Count tokens in a log file or section')
|
|
108
|
+
.argument('<file>', 'Path to log file')
|
|
109
|
+
.option('-s, --section <label>', 'Count tokens in section')
|
|
110
|
+
.option('-e, --end-section <label>', 'End section marker label')
|
|
111
|
+
.action(async (file, options) => {
|
|
112
|
+
try {
|
|
113
|
+
let content;
|
|
114
|
+
if (options.section) {
|
|
115
|
+
const extractor = new LogExtractor_1.LogExtractor(file);
|
|
116
|
+
content = extractor.extractSection(options.section, options.endSection);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
content = await fs.promises.readFile(file, 'utf8');
|
|
120
|
+
}
|
|
121
|
+
const counter = new TokenCounter_1.TokenCounter();
|
|
122
|
+
const tokenCount = counter.countTokens(content);
|
|
123
|
+
console.log(`Token count: ${tokenCount}`);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.error(`Error: ${error.message}`);
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
// Export command
|
|
131
|
+
program
|
|
132
|
+
.command('export')
|
|
133
|
+
.description('Export filtered logs to a new file')
|
|
134
|
+
.argument('<source>', 'Source log file')
|
|
135
|
+
.argument('<destination>', 'Destination file')
|
|
136
|
+
.option('-s, --section <label>', 'Export section by marker label')
|
|
137
|
+
.option('-e, --end-section <label>', 'End section marker label')
|
|
138
|
+
.option('-t, --time-range <start,end>', 'Export by time range (ISO 8601 timestamps)')
|
|
139
|
+
.option('-l, --level <level>', 'Export by minimum log level (DEBUG, INFO, WARN, ERROR, FATAL)')
|
|
140
|
+
.action(async (source, destination, options) => {
|
|
141
|
+
try {
|
|
142
|
+
const extractor = new LogExtractor_1.LogExtractor(source);
|
|
143
|
+
let result;
|
|
144
|
+
if (options.section) {
|
|
145
|
+
result = extractor.extractSection(options.section, options.endSection);
|
|
146
|
+
}
|
|
147
|
+
else if (options.timeRange) {
|
|
148
|
+
const [start, end] = options.timeRange.split(',');
|
|
149
|
+
result = extractor.extractTimeRange(new Date(start), new Date(end));
|
|
150
|
+
}
|
|
151
|
+
else if (options.level) {
|
|
152
|
+
const levelMap = {
|
|
153
|
+
'DEBUG': types_1.LogLevel.DEBUG,
|
|
154
|
+
'INFO': types_1.LogLevel.INFO,
|
|
155
|
+
'WARN': types_1.LogLevel.WARN,
|
|
156
|
+
'ERROR': types_1.LogLevel.ERROR,
|
|
157
|
+
'FATAL': types_1.LogLevel.FATAL
|
|
158
|
+
};
|
|
159
|
+
const level = levelMap[options.level.toUpperCase()];
|
|
160
|
+
if (level === undefined) {
|
|
161
|
+
console.error(`Invalid log level: ${options.level}`);
|
|
162
|
+
process.exit(1);
|
|
163
|
+
}
|
|
164
|
+
result = extractor.extractByLevel(level);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// Export entire file
|
|
168
|
+
result = await fs.promises.readFile(source, 'utf8');
|
|
169
|
+
}
|
|
170
|
+
await extractor.exportSection(result, destination);
|
|
171
|
+
console.log(`Logs exported to ${destination}`);
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
console.error(`Error: ${error.message}`);
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
program.parse();
|
|
179
|
+
//# sourceMappingURL=axon-cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"axon-cli.js","sourceRoot":"","sources":["../../src/cli/axon-cli.ts"],"names":[],"mappings":";;AAEA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,yCAAoC;AACpC,4DAAyD;AACzD,2CAA2C;AAC3C,wDA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C,CAAC,CAAC;YAClB,CAAC;YACD,MAAM,GAAG,SAAS,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,qBAAqB;YACrB,MAAM,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACnD,OAAO,CAAC,GAAG,CAAC,oBAAoB,WAAW,EAAE,CAAC,CAAC;IACjD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,UAAW,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LogExtractor class
|
|
3
|
+
* Provides utilities for extracting and filtering log entries from TOON-formatted log files
|
|
4
|
+
*/
|
|
5
|
+
import { LogLevel, LogEntry } from '../logger/types';
|
|
6
|
+
/**
|
|
7
|
+
* LogExtractor class
|
|
8
|
+
* Loads and parses log files, provides methods for extracting sections, time ranges, and filtering by level
|
|
9
|
+
*/
|
|
10
|
+
export declare class LogExtractor {
|
|
11
|
+
private logFilePath;
|
|
12
|
+
private parser;
|
|
13
|
+
private entries;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new LogExtractor instance
|
|
16
|
+
* @param logFilePath - Path to the log file to extract from
|
|
17
|
+
*/
|
|
18
|
+
constructor(logFilePath: string);
|
|
19
|
+
/**
|
|
20
|
+
* Loads and parses the log file
|
|
21
|
+
* @private
|
|
22
|
+
*/
|
|
23
|
+
private loadLogFile;
|
|
24
|
+
/**
|
|
25
|
+
* Gets all entries (for testing purposes)
|
|
26
|
+
* @returns Array of log entries and markers
|
|
27
|
+
*/
|
|
28
|
+
getEntries(): (LogEntry | string)[];
|
|
29
|
+
/**
|
|
30
|
+
* Extracts a section of logs between markers
|
|
31
|
+
* @param startMarker - The label of the start marker
|
|
32
|
+
* @param endMarker - Optional label of the end marker. If not provided, extracts to end of file
|
|
33
|
+
* @returns TOON-formatted string containing the extracted section
|
|
34
|
+
*/
|
|
35
|
+
extractSection(startMarker: string, endMarker?: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Serializes entries back to TOON format
|
|
38
|
+
* @param entries - Array of log entries and markers
|
|
39
|
+
* @returns TOON-formatted string
|
|
40
|
+
* @private
|
|
41
|
+
*/
|
|
42
|
+
private serializeEntries;
|
|
43
|
+
/**
|
|
44
|
+
* Extracts log entries within a time range
|
|
45
|
+
* @param start - Start date/time
|
|
46
|
+
* @param end - End date/time
|
|
47
|
+
* @returns TOON-formatted string containing entries within the time range
|
|
48
|
+
*/
|
|
49
|
+
extractTimeRange(start: Date, end: Date): string;
|
|
50
|
+
/**
|
|
51
|
+
* Extracts log entries at or above a specific log level
|
|
52
|
+
* @param level - Minimum log level to extract
|
|
53
|
+
* @returns TOON-formatted string containing entries at or above the specified level
|
|
54
|
+
*/
|
|
55
|
+
extractByLevel(level: LogLevel): string;
|
|
56
|
+
/**
|
|
57
|
+
* Exports a section to a new file
|
|
58
|
+
* @param section - TOON-formatted section string
|
|
59
|
+
* @param outputPath - Path to write the exported section
|
|
60
|
+
* @returns Promise that resolves when export is complete
|
|
61
|
+
*/
|
|
62
|
+
exportSection(section: string, outputPath: string): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=LogExtractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogExtractor.d.ts","sourceRoot":"","sources":["../../src/extractor/LogExtractor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,OAAO,CAA6B;IAE5C;;;OAGG;gBACS,WAAW,EAAE,MAAM;IAU/B;;;OAGG;IACH,OAAO,CAAC,WAAW;IA8BnB;;;OAGG;IACH,UAAU,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,EAAE;IAInC;;;;;OAKG;IACH,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM;IAuC/D;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAaxB;;;;;OAKG;IACH,gBAAgB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,MAAM;IA0BhD;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM;IAkBvC;;;;;OAKG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAmBxE"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* LogExtractor class
|
|
4
|
+
* Provides utilities for extracting and filtering log entries from TOON-formatted log files
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.LogExtractor = void 0;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const TOONParser_1 = require("../parser/TOONParser");
|
|
43
|
+
/**
|
|
44
|
+
* LogExtractor class
|
|
45
|
+
* Loads and parses log files, provides methods for extracting sections, time ranges, and filtering by level
|
|
46
|
+
*/
|
|
47
|
+
class LogExtractor {
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new LogExtractor instance
|
|
50
|
+
* @param logFilePath - Path to the log file to extract from
|
|
51
|
+
*/
|
|
52
|
+
constructor(logFilePath) {
|
|
53
|
+
this.entries = [];
|
|
54
|
+
if (!logFilePath || typeof logFilePath !== 'string') {
|
|
55
|
+
throw new Error('Invalid logFilePath: must be a non-empty string');
|
|
56
|
+
}
|
|
57
|
+
this.logFilePath = logFilePath;
|
|
58
|
+
this.parser = new TOONParser_1.TOONParser();
|
|
59
|
+
this.loadLogFile();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Loads and parses the log file
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
loadLogFile() {
|
|
66
|
+
try {
|
|
67
|
+
if (!fs.existsSync(this.logFilePath)) {
|
|
68
|
+
throw new Error(`Log file not found: ${this.logFilePath}`);
|
|
69
|
+
}
|
|
70
|
+
const content = fs.readFileSync(this.logFilePath, 'utf8');
|
|
71
|
+
const lines = content.split('\n').filter(line => line.trim().length > 0);
|
|
72
|
+
// Parse each entry (could be a log entry or a marker)
|
|
73
|
+
for (const line of lines) {
|
|
74
|
+
if (line.startsWith('=== MARKER:')) {
|
|
75
|
+
// It's a marker, keep as string
|
|
76
|
+
this.entries.push(line);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
try {
|
|
80
|
+
// Try to parse as TOON log entry
|
|
81
|
+
const parsed = this.parser.parse(line);
|
|
82
|
+
this.entries.push(parsed);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// If parsing fails, skip the line
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new Error(`Failed to load log file: ${error.message}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Gets all entries (for testing purposes)
|
|
97
|
+
* @returns Array of log entries and markers
|
|
98
|
+
*/
|
|
99
|
+
getEntries() {
|
|
100
|
+
return [...this.entries];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Extracts a section of logs between markers
|
|
104
|
+
* @param startMarker - The label of the start marker
|
|
105
|
+
* @param endMarker - Optional label of the end marker. If not provided, extracts to end of file
|
|
106
|
+
* @returns TOON-formatted string containing the extracted section
|
|
107
|
+
*/
|
|
108
|
+
extractSection(startMarker, endMarker) {
|
|
109
|
+
const markerRegex = /^=== MARKER: (.+) \| (\d+) ===$/;
|
|
110
|
+
let inSection = false;
|
|
111
|
+
let sectionEntries = [];
|
|
112
|
+
for (const entry of this.entries) {
|
|
113
|
+
if (typeof entry === 'string') {
|
|
114
|
+
// It's a marker
|
|
115
|
+
const match = entry.match(markerRegex);
|
|
116
|
+
if (match) {
|
|
117
|
+
const label = match[1];
|
|
118
|
+
if (label === startMarker) {
|
|
119
|
+
inSection = true;
|
|
120
|
+
sectionEntries.push(entry); // Include start marker
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (endMarker && label === endMarker) {
|
|
124
|
+
sectionEntries.push(entry); // Include end marker
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (inSection) {
|
|
129
|
+
sectionEntries.push(entry);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// It's a log entry
|
|
134
|
+
if (inSection) {
|
|
135
|
+
sectionEntries.push(entry);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Serialize entries back to TOON format
|
|
140
|
+
return this.serializeEntries(sectionEntries);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Serializes entries back to TOON format
|
|
144
|
+
* @param entries - Array of log entries and markers
|
|
145
|
+
* @returns TOON-formatted string
|
|
146
|
+
* @private
|
|
147
|
+
*/
|
|
148
|
+
serializeEntries(entries) {
|
|
149
|
+
const { TOONSerializer } = require('../serializer/TOONSerializer');
|
|
150
|
+
const serializer = new TOONSerializer();
|
|
151
|
+
return entries.map(entry => {
|
|
152
|
+
if (typeof entry === 'string') {
|
|
153
|
+
return entry;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
return serializer.serialize(entry);
|
|
157
|
+
}
|
|
158
|
+
}).join('\n');
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Extracts log entries within a time range
|
|
162
|
+
* @param start - Start date/time
|
|
163
|
+
* @param end - End date/time
|
|
164
|
+
* @returns TOON-formatted string containing entries within the time range
|
|
165
|
+
*/
|
|
166
|
+
extractTimeRange(start, end) {
|
|
167
|
+
const startTime = start.getTime();
|
|
168
|
+
const endTime = end.getTime();
|
|
169
|
+
const filteredEntries = [];
|
|
170
|
+
for (const entry of this.entries) {
|
|
171
|
+
if (typeof entry === 'string') {
|
|
172
|
+
// It's a marker - check timestamp in marker
|
|
173
|
+
const match = entry.match(/\| (\d+) ===$/);
|
|
174
|
+
if (match) {
|
|
175
|
+
const timestamp = parseInt(match[1]);
|
|
176
|
+
if (timestamp >= startTime && timestamp <= endTime) {
|
|
177
|
+
filteredEntries.push(entry);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// It's a log entry - check ts field
|
|
183
|
+
if (entry.ts >= startTime && entry.ts <= endTime) {
|
|
184
|
+
filteredEntries.push(entry);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return this.serializeEntries(filteredEntries);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Extracts log entries at or above a specific log level
|
|
192
|
+
* @param level - Minimum log level to extract
|
|
193
|
+
* @returns TOON-formatted string containing entries at or above the specified level
|
|
194
|
+
*/
|
|
195
|
+
extractByLevel(level) {
|
|
196
|
+
const filteredEntries = [];
|
|
197
|
+
for (const entry of this.entries) {
|
|
198
|
+
if (typeof entry === 'string') {
|
|
199
|
+
// Include all markers
|
|
200
|
+
filteredEntries.push(entry);
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
// Filter by log level
|
|
204
|
+
if (entry.lvl >= level) {
|
|
205
|
+
filteredEntries.push(entry);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return this.serializeEntries(filteredEntries);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Exports a section to a new file
|
|
213
|
+
* @param section - TOON-formatted section string
|
|
214
|
+
* @param outputPath - Path to write the exported section
|
|
215
|
+
* @returns Promise that resolves when export is complete
|
|
216
|
+
*/
|
|
217
|
+
async exportSection(section, outputPath) {
|
|
218
|
+
if (!outputPath || typeof outputPath !== 'string') {
|
|
219
|
+
throw new Error('Invalid outputPath: must be a non-empty string');
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
// Ensure directory exists
|
|
223
|
+
const path = require('path');
|
|
224
|
+
const dir = path.dirname(outputPath);
|
|
225
|
+
if (!fs.existsSync(dir)) {
|
|
226
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
227
|
+
}
|
|
228
|
+
// Write section to file
|
|
229
|
+
await fs.promises.writeFile(outputPath, section, 'utf8');
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
throw new Error(`Failed to export section: ${error.message}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.LogExtractor = LogExtractor;
|
|
237
|
+
//# sourceMappingURL=LogExtractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogExtractor.js","sourceRoot":"","sources":["../../src/extractor/LogExtractor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qDAAkD;AAGlD;;;GAGG;AACH,MAAa,YAAY;IAKvB;;;OAGG;IACH,YAAY,WAAmB;QANvB,YAAO,GAA0B,EAAE,CAAC;QAO1C,IAAI,CAAC,WAAW,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACrE,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAED;;;OAGG;IACK,W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 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extractor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LogExtractor = void 0;
|
|
4
|
+
var LogExtractor_1 = require("./LogExtractor");
|
|
5
|
+
Object.defineProperty(exports, "LogExtractor", { enumerable: true, get: function () { return LogExtractor_1.LogExtractor; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extractor/index.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAArC,4GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Manager for Browser
|
|
3
|
+
* Handles log storage using localStorage or IndexedDB
|
|
4
|
+
*/
|
|
5
|
+
import { FileManagerConfig } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* BrowserFileManager class
|
|
8
|
+
* Manages log storage in browser environments using localStorage or IndexedDB
|
|
9
|
+
*/
|
|
10
|
+
export declare class BrowserFileManager {
|
|
11
|
+
private config;
|
|
12
|
+
private buffer;
|
|
13
|
+
private storageKey;
|
|
14
|
+
private useIndexedDB;
|
|
15
|
+
private dbName;
|
|
16
|
+
private storeName;
|
|
17
|
+
private flushTimer;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new BrowserFileManager instance
|
|
20
|
+
* @param config - Configuration for file operations
|
|
21
|
+
*/
|
|
22
|
+
constructor(config: FileManagerConfig);
|
|
23
|
+
/**
|
|
24
|
+
* Detects whether to use localStorage or IndexedDB
|
|
25
|
+
* Uses localStorage for small logs, IndexedDB for larger logs
|
|
26
|
+
*/
|
|
27
|
+
private detectStorageMechanism;
|
|
28
|
+
/**
|
|
29
|
+
* Starts the auto-flush timer
|
|
30
|
+
*/
|
|
31
|
+
private startFlushTimer;
|
|
32
|
+
/**
|
|
33
|
+
* Stops the auto-flush timer
|
|
34
|
+
*/
|
|
35
|
+
private stopFlushTimer;
|
|
36
|
+
/**
|
|
37
|
+
* Writes a TOON-formatted string to the buffer
|
|
38
|
+
* @param toonString - The TOON-formatted log entry
|
|
39
|
+
*/
|
|
40
|
+
write(toonString: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Flushes the buffer to storage
|
|
43
|
+
* Writes all buffered entries to localStorage or IndexedDB
|
|
44
|
+
*/
|
|
45
|
+
flush(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Writes data to localStorage
|
|
48
|
+
* @param data - The data to write
|
|
49
|
+
*/
|
|
50
|
+
private writeToLocalStorage;
|
|
51
|
+
/**
|
|
52
|
+
* Writes data to IndexedDB
|
|
53
|
+
* @param data - The data to write
|
|
54
|
+
*/
|
|
55
|
+
private writeToIndexedDB;
|
|
56
|
+
/**
|
|
57
|
+
* Opens IndexedDB connection
|
|
58
|
+
* @returns Promise that resolves to IDBDatabase
|
|
59
|
+
*/
|
|
60
|
+
private openIndexedDB;
|
|
61
|
+
/**
|
|
62
|
+
* Migrates data from localStorage to IndexedDB
|
|
63
|
+
* @param data - The data to migrate
|
|
64
|
+
*/
|
|
65
|
+
private migrateToIndexedDB;
|
|
66
|
+
/**
|
|
67
|
+
* Downloads logs as a file
|
|
68
|
+
* Triggers browser download of all log data
|
|
69
|
+
*/
|
|
70
|
+
downloadLogs(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Reads all data from IndexedDB
|
|
73
|
+
* @returns Promise that resolves to concatenated log data
|
|
74
|
+
*/
|
|
75
|
+
private readFromIndexedDB;
|
|
76
|
+
/**
|
|
77
|
+
* Closes the file manager
|
|
78
|
+
* Flushes remaining buffer
|
|
79
|
+
*/
|
|
80
|
+
close(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Handles errors by invoking the error callback
|
|
83
|
+
* @param error - The error to handle
|
|
84
|
+
*/
|
|
85
|
+
private handleError;
|
|
86
|
+
/**
|
|
87
|
+
* Gets the current buffer size (for testing)
|
|
88
|
+
* @returns Number of entries in the buffer
|
|
89
|
+
*/
|
|
90
|
+
getBufferSize(): number;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the current buffer (for testing)
|
|
93
|
+
* @returns Copy of the current buffer
|
|
94
|
+
*/
|
|
95
|
+
getBuffer(): ReadonlyArray<string>;
|
|
96
|
+
/**
|
|
97
|
+
* Gets whether IndexedDB is being used (for testing)
|
|
98
|
+
* @returns True if using IndexedDB, false if using localStorage
|
|
99
|
+
*/
|
|
100
|
+
isUsingIndexedDB(): boolean;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=BrowserFileManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BrowserFileManager.d.ts","sourceRoot":"","sources":["../../src/file-manager/BrowserFileManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,UAAU,CAAuB;IAEzC;;;OAGG;gBACS,MAAM,EAAE,iBAAiB;IAarC;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAc9B;;OAEG;IACH,OAAO,CAAC,eAAe;IAMvB;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;;OAGG;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAS/B;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB5B;;;OAGG;YACW,mBAAmB;IA0BjC;;;OAGG;YACW,gBAAgB;IAmB9B;;;OAGG;YACW,aAAa;IAoB3B;;;OAGG;YACW,kBAAkB;IAYhC;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BnC;;;OAGG;YACW,iBAAiB;IAkB/B;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B;;;OAGG;IACH,OAAO,CAAC,WAAW;IAQnB;;;OAGG;IACH,aAAa,IAAI,MAAM;IAIvB;;;OAGG;IACH,SAAS,IAAI,aAAa,CAAC,MAAM,CAAC;IAIlC;;;OAGG;IACH,gBAAgB,IAAI,OAAO;CAG5B"}
|