UNPKG

@edgestore/server

Version:

Upload files with ease from React/Next.js

45 lines (41 loc) 1.31 kB
import { i as isDev } from './shared-64e9c30c.js'; /* eslint-disable no-console */ const logLevel = ['debug', 'info', 'warn', 'error', 'none']; class Logger { constructor(logLevel) { this.logLevel = logLevel ?? (isDev() ? 'info' : 'error'); } shouldLog(level) { return logLevel.indexOf(level) >= logLevel.indexOf(this.logLevel); } debug(message, ...optionalParams) { if (this.shouldLog('debug')) { console.debug('[EdgeStoreDebug]', message, ...optionalParams); } } info(message, ...optionalParams) { if (this.shouldLog('info')) { console.info('[EdgeStoreInfo]', message, ...optionalParams); } } warn(message, ...optionalParams) { if (this.shouldLog('warn')) { console.warn('[EdgeStoreWarn]', message, ...optionalParams); } } error(message, ...optionalParams) { if (this.shouldLog('error')) { console.error('[EdgeStoreError]', message, ...optionalParams); } } } /** * Check if a route matches the current path. */ function matchPath(pathname, route) { // Allow trailing slash // Allow query string const regex = new RegExp(`${route}/?(\\?.*)?$`); return regex.test(pathname); } export { Logger as L, matchPath as m };