@coko/server
Version:
Reusable server for use by Coko's projects
77 lines • 2.6 kB
JavaScript
;
/* eslint-disable no-console, class-methods-use-this */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const env_1 = require("../utils/env");
const BULLET = '\u25cf';
const CHECK = '\u2713';
const COG = '\u2699';
const CROSS = '\u2718';
const HOURGLASS = '\u23F3';
const PICKAXE = '\u26CF';
const isTest = process.env.NODE_ENV === 'test';
const suppress = isTest && (0, env_1.env)('SUPPRESS_LOGGER_IN_TEST_ENV', { type: 'boolean' });
class InternalLogger {
primary = chalk_1.default.hex('#4169E1');
builder(str, options = {}) {
if (suppress)
return;
console.log(chalk_1.default.yellow(`${options.newLineBefore ? '\n' : ''}${COG} [builder] ${str}${options.newLineAfter ? '\n' : ''}`));
}
error(str) {
if (suppress)
return;
console.log(`${chalk_1.default.red(CROSS)} ${str}`);
}
init(str, options = {}) {
if (suppress)
return;
console.log(chalk_1.default.yellow(`${options.newLineBefore ? '\n' : ''}${PICKAXE} ${str} ${PICKAXE}${options.newLineAfter ? '\n' : ''}`));
}
nodemon(str, options = {}) {
if (suppress)
return;
console.log(chalk_1.default.yellow(`${options.newLineBefore ? '\n' : ''}${COG} [nodemon] ${str}${options.newLineAfter ? '\n' : ''}`));
}
point(str, indent = 0) {
if (suppress)
return;
console.log(`${' '.repeat(indent)}${this.primary(BULLET)} ${str}`);
}
report(header, str) {
if (suppress)
return;
console.log(`${chalk_1.default.magenta(header)} ${str}`);
}
section(str) {
if (suppress)
return;
console.log(`\n${this.primary.bold.underline(`${str}`)}`);
}
success(str, indent = 0) {
if (suppress)
return;
console.log(`${' '.repeat(indent)}${chalk_1.default.green(CHECK)} ${str}`);
}
wait(str) {
if (suppress)
return;
console.log(`${HOURGLASS} ${str}`);
}
warn(str) {
if (suppress)
return;
console.log(`${chalk_1.default.yellow(BULLET)} ${str}`);
}
work(str) {
if (suppress)
return;
console.log(chalk_1.default.yellow(`🛠 ${str}`));
}
}
const internalLogger = new InternalLogger();
exports.default = internalLogger;
//# sourceMappingURL=internals.js.map