UNPKG

expo-passkey

Version:

Passkey authentication for Expo apps with Better Auth integration

50 lines 1.39 kB
/** * @file Logger utility * @description Configurable logger for the server implementation */ /** * Creates a logger instance with configurable log levels */ export const createLogger = (options = {}) => { const enabled = options.enabled !== undefined ? options.enabled : process.env.NODE_ENV === "development"; const opts = { enabled, level: options.level ?? "info", }; // Log level priority const logLevels = { debug: 0, info: 1, warn: 2, error: 3, }; // Check if a level should be logged based on the configured level const shouldLog = (level) => { return opts.enabled && logLevels[level] >= logLevels[opts.level]; }; return { debug: (...args) => { if (shouldLog("debug")) { console.debug("[ExpoPasskey]", ...args); } }, info: (...args) => { if (shouldLog("info")) { console.info("[ExpoPasskey]", ...args); } }, warn: (...args) => { if (shouldLog("warn")) { console.warn("[ExpoPasskey]", ...args); } }, error: (...args) => { if (shouldLog("error")) { console.error("[ExpoPasskey]", ...args); } }, }; }; //# sourceMappingURL=logger.js.map