UNPKG

entangle.ts

Version:

A declarative, event-driven framework for orchestrating business logic in TypeScript & Node.js applications.

31 lines (30 loc) 839 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Logging = void 0; const Logging_types_1 = require("../shared/types/Logging.types"); class Logging { constructor(mode, logger, logTypes = [ Logging_types_1.ELogType.CREATION, Logging_types_1.ELogType.INTERACTION, Logging_types_1.ELogType.ERROR, ]) { this.mode = mode; this.logger = logger; this.logTypes = logTypes; } log(logDetails) { if (this.canLog(logDetails)) { this.logger.log(logDetails); } } canLog(logDetails) { if (this.mode === 'off') { return false; } if (this.mode === 'debug') { return true; } return this.logTypes.includes(logDetails.type); } } exports.Logging = Logging;