From fe62cadd6fb4a7e49f7d59401fc74ae0411e32a7 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 26 Aug 2024 21:17:43 -0700 Subject: typescript --- lib/logging.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 lib/logging.ts (limited to 'lib/logging.ts') diff --git a/lib/logging.ts b/lib/logging.ts new file mode 100644 index 00000000..4913839a --- /dev/null +++ b/lib/logging.ts @@ -0,0 +1,12 @@ +import pino from "pino"; + +export let l = (...msgs) => pino().info(msgs.join(" ")); +export let warn = (...msgs) => pino().warn(msgs.join(" ")); +export let err = (...msgs) => pino().error(msgs.join(" ")); + +export let line = () => { + let stack = new Error().stack; + let stackLine = stack.split("\n")[1]; + let match = stackLine.match(/at\s+(.*):(\d+):(\d+)/); + return `${match[1]}:${match[2]}`; +}; -- cgit v1.2.3