diff --git a/deno/logging.ts b/deno/logging.ts new file mode 100644 index 0000000..6e629f8 --- /dev/null +++ b/deno/logging.ts @@ -0,0 +1,44 @@ +// internal-logging.ts + +// FIXME: Move this to somewhere more appropriate +type AtLeastOne = [T, ...T[]]; + +type MessageSource = "logging" | "diagnostic" | "user"; + +type Message = { + // FIXME: number probably isn't what we want here + timestamp: number; + source: MessageSource; + + text: AtLeastOne; +}; + +const m1: Message = { timestamp: 123, source: "logging", text: ["foo"] }; +const m2: Message = { + timestamp: 321, + source: "diagnostic", + text: ["ok", "whatever"], +}; + +type FilterArgument = { + limit?: number; + before?: number; + after?: number; + + // FIXME: add offsets to use instead of or in addition to before/after + + match?: (string | RegExp)[]; +}; + +const log = (_message: Message) => { + // WRITEME +}; + +const getLogs = (filter: FilterArgument) => { + // WRITEME +}; + +// FIXME: there's scope for more specialized functions although they +// probably should be defined in terms of the basic ones here. + +export { getLogs, log };