-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
21 lines (19 loc) · 830 Bytes
/
index.ts
File metadata and controls
21 lines (19 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { mkdtempSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { Context } from "./src/model";
export { ColumnIndex, Context, LogLine, Entry, EntryIterFunc, EntryIter } from "./src/model"
export { insert, insertFunc, latestLogStat, getDatabase } from "./src/insert"
export { iterLogs } from "./src/read-file"
export const ctx = (part?: Partial<Context>): Context => ({
entryFields: new Set<string>(),
entryRegex: /^(?<timestamp>[^\t ]+)[\t ](?<body>.+)$/,
sqliteTable: "logs",
sqliteRoot: mkdtempSync(join(tmpdir(), "/")),
sqliteInMemory: false,
sqliteColumnIndexes: [],
logfileRoot: mkdtempSync(join(tmpdir(), "/")),
logfileAfter: null,
logfileBefore: null,
...Object.fromEntries(Object.entries(part || {}).filter(([_, value]) => value !== undefined)),
})