@convex-dev/geospatial
Version:
A geospatial index for Convex
41 lines • 1.18 kB
JavaScript
import { v } from "convex/values";
export const logLevel = v.union(v.literal("DEBUG"), v.literal("INFO"), v.literal("WARN"), v.literal("ERROR"));
export function createLogger(level) {
const levelIndex = ["DEBUG", "INFO", "WARN", "ERROR"].indexOf(level);
if (levelIndex === -1) {
throw new Error(`Invalid log level: ${level}`);
}
return {
debug: (...args) => {
if (levelIndex <= 0) {
console.debug(...args);
}
},
info: (...args) => {
if (levelIndex <= 1) {
console.info(...args);
}
},
warn: (...args) => {
if (levelIndex <= 2) {
console.warn(...args);
}
},
error: (...args) => {
if (levelIndex <= 3) {
console.error(...args);
}
},
time: (label) => {
if (levelIndex <= 1) {
console.time(label);
}
},
timeEnd: (label) => {
if (levelIndex <= 1) {
console.timeEnd(label);
}
},
};
}
//# sourceMappingURL=logging.js.map