12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 'use strict';
- const { Colorizer } = require('./colorize');
- const { Padder } = require('./pad-levels');
- const { configs, MESSAGE } = require('triple-beam');
- class CliFormat {
- constructor(opts = {}) {
- if (!opts.levels) {
- opts.levels = configs.cli.levels;
- }
- this.colorizer = new Colorizer(opts);
- this.padder = new Padder(opts);
- this.options = opts;
- }
-
- transform(info, opts) {
- this.colorizer.transform(
- this.padder.transform(info, opts),
- opts
- );
- info[MESSAGE] = `${info.level}:${info.message}`;
- return info;
- }
- }
- module.exports = opts => new CliFormat(opts);
- module.exports.Format = CliFormat;
|