@mikro-orm/core
Version:
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.
31 lines (30 loc) • 854 B
JavaScript
import { DefaultLogger } from './DefaultLogger.js';
/**
* A basic logger that provides fully formatted output without color
*/
export class SimpleLogger extends DefaultLogger {
/**
* @inheritDoc
*/
log(namespace, message, context) {
if (!this.isEnabled(namespace, context)) {
return;
}
// clean up the whitespace
message = message.replace(/\n/g, '').replace(/ +/g, ' ').trim();
const label = context?.label ? `(${context.label}) ` : '';
this.writer(`[${namespace}] ${label}${message}`);
}
/**
* @inheritDoc
*/
logQuery(context) {
if (!this.isEnabled('query', context)) {
return;
}
return this.log('query', context.query, context);
}
static create(options) {
return new SimpleLogger(options);
}
}