langflow-chatbot
Version:
Add a Langflow-powered chatbot to your website.
47 lines (46 loc) • 1.16 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = void 0;
const LOG_LEVELS = {
error: 0,
warn: 1,
info: 2,
debug: 3,
};
class Logger {
constructor(level = 'warn', prefix = 'LangflowChatbot') {
this.level = level;
this.prefix = prefix;
}
setLevel(level) {
this.level = level;
}
shouldLog(level) {
return LOG_LEVELS[level] <= LOG_LEVELS[this.level];
}
format(level, ...args) {
const tag = `[${this.prefix}] [${level.toUpperCase()}]`;
return [tag, ...args];
}
error(...args) {
if (this.shouldLog('error')) {
console.error(...this.format('error', ...args));
}
}
warn(...args) {
if (this.shouldLog('warn')) {
console.warn(...this.format('warn', ...args));
}
}
info(...args) {
if (this.shouldLog('info')) {
console.info(...this.format('info', ...args));
}
}
debug(...args) {
if (this.shouldLog('debug')) {
console.debug(...this.format('debug', ...args));
}
}
}
exports.Logger = Logger;