UNPKG

@edgestore/server

Version:

Upload files with ease from React/Next.js

66 lines (61 loc) 1.72 kB
'use strict'; var shared = require('./shared-4ec2dc90.js'); /* eslint-disable no-console */ function _define_property(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } const logLevel = [ 'debug', 'info', 'warn', 'error', 'none' ]; class Logger { 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); } } constructor(logLevel){ _define_property(this, "logLevel", void 0); this.logLevel = logLevel ?? (shared.isDev() ? 'info' : 'error'); } } /** * 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); } exports.Logger = Logger; exports.matchPath = matchPath;