@edgestore/server
Version:
Upload files with ease from React/Next.js
63 lines (59 loc) • 1.69 kB
JavaScript
import { i as isDev } from './shared-c6527780.mjs';
/* 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 ?? (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);
}
export { Logger as L, matchPath as m };