openai-mock-api
Version:
A mock OpenAI API server for testing LLM applications
39 lines • 1.38 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = void 0;
const winston_1 = __importDefault(require("winston"));
class Logger {
constructor(logFile, verbose = false) {
const transports = [];
if (logFile) {
transports.push(new winston_1.default.transports.File({
filename: logFile,
format: winston_1.default.format.combine(winston_1.default.format.timestamp(), winston_1.default.format.json()),
}));
}
transports.push(new winston_1.default.transports.Console({
format: winston_1.default.format.combine(winston_1.default.format.colorize(), winston_1.default.format.simple()),
}));
this.logger = winston_1.default.createLogger({
level: verbose ? 'debug' : 'info',
transports,
});
}
info(message, meta) {
this.logger.info(message, meta);
}
debug(message, meta) {
this.logger.debug(message, meta);
}
warn(message, meta) {
this.logger.warn(message, meta);
}
error(message, meta) {
this.logger.error(message, meta);
}
}
exports.Logger = Logger;
//# sourceMappingURL=logger.js.map