How to use the kleur.enabled function in kleur

To help you get started, we’ve selected a few kleur examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github moleculerjs / moleculer / test / unit / loggers / console.spec.js View on Github external
/* eslint-disable no-console */
"use strict";

const kleur = require("kleur");
kleur.enabled = false;

const ConsoleLogger = require("../../../src/loggers/console");
const ServiceBroker = require("../../../src/service-broker");
const LoggerFactory = require("../../../src/logger-factory");

const lolex = require("lolex");

const broker = new ServiceBroker({ logger: false });

describe("Test Console logger class", () => {

	describe("Test Constructor", () => {

		it("should create with default options", () => {
			const logger = new ConsoleLogger();
github moleculerjs / moleculer / src / loggers / console.js View on Github external
init(loggerFactory) {
		super.init(loggerFactory);

		if (!this.opts.colors)
			kleur.enabled = false;

		this.objectPrinter = this.opts.objectPrinter ? this.opts.objectPrinter : o => util.inspect(o, { showHidden: false, depth: 2, colors: kleur.enabled, breakLength: Number.POSITIVE_INFINITY });

		// Generate colorful log level names
		this.levelColorStr = BaseLogger.LEVELS.reduce((a, level) => {
			a[level] = getColor(level)(_.padEnd(level.toUpperCase(), 5));
			return a;
		}, {});

		if (this.opts.colors && this.opts.moduleColors === true) {
			this.opts.moduleColors = ["cyan", "yellow", "green", "magenta", "red", "blue", "grey", /*"white,"*/
				"bold.cyan", "bold.yellow", "bold.green", "bold.magenta", "bold.red", "bold.blue", "bold.grey"];
		}
		this.colorCnt = 0;
	}
github mehmet-erim / symlink-manager / src / utils / log.js View on Github external
import ora from 'ora';
import kleur from 'kleur';
kleur.enabled = require('color-support').level;

export class Log {
  static log(text, color) {
    console.log(kleur[color]().bold(text));
  }

  static info(text) {
    this.log(text, 'cyan');
  }

  static primary(text) {
    this.log(text, 'blue');
  }

  static success(text) {
    this.log(text, 'green');
github moleculerjs / moleculer / src / metrics / reporters / console.js View on Github external
constructor(opts) {
		super(opts);

		this.opts = _.defaultsDeep(this.opts, {
			interval: 5 * 1000,
			logger: null,
			colors: true,
			onlyChanges: true,
		});

		if (!this.opts.colors)
			kleur.enabled = false;

		this.lastChanges = new Set();
	}
github adonisjs / ace / src / Kernel / index.js View on Github external
outputHelp (options, colorize = process.env.NO_ANSI === 'false') {
    const strings = []
    const commandsGroup = this._groupCommands()
    const groupNames = _.keys(commandsGroup).sort()
    const maxWidth = this._largestCommandLength(_.map(options, (option) => option.long)) + 2

    if (!colorize) {
      kleur.enabled = false
    }

    /**
     * Usage lines
     */
    strings.push(kleur.magenta.bold('Usage:'))
    strings.push('  command [arguments] [options]')

    /**
     * Only print global options when they exists.
     */
    if (_.size(options)) {
      strings.push(WHITE_SPACE)
      strings.push(kleur.magenta.bold('Global Options:'))
      _.each(options, (option) => {
        strings.push(`  ${kleur.blue(_.padEnd(option.long, maxWidth))} ${option.description}`)
github adonisjs / ace / src / Command / index.js View on Github external
constructor () {
    this.chalk = kleur

    if (process.env.NO_ANSI === 'false') {
      kleur.enabled = false
    }

    /**
     * List of icons
     *
     * @type {Object}
     */
    this.iconsMain = {
      info: this.chalk.cyan('ℹ'),
      success: this.chalk.green('✔'),
      warn: this.chalk.yellow('⚠'),
      error: this.chalk.red('✖')
    }

    /**
     * The icons to be used on windows
github moleculerjs / moleculer / src / tracing / exporters / console.js View on Github external
constructor(opts) {
		super(opts);

		this.opts = _.defaultsDeep(this.opts, {
			logger: null,
			colors: true,
			width: 100,
			gaugeWidth: 40
		});

		if (!this.opts.colors)
			kleur.enabled = false;

		this.spans = {};
	}
github moleculerjs / moleculer / src / loggers / console.js View on Github external
		this.objectPrinter = this.opts.objectPrinter ? this.opts.objectPrinter : o => util.inspect(o, { showHidden: false, depth: 2, colors: kleur.enabled, breakLength: Number.POSITIVE_INFINITY });
github adonisjs / ace / src / Kernel / index.js View on Github external
strings.push(`  ${kleur.blue(_.padEnd(option.long, maxWidth))} ${option.description}`)
      })
    }

    /**
     * Only print commands when they are available
     */
    if (_.size(groupNames)) {
      strings.push(WHITE_SPACE)
      strings.push(kleur.magenta.bold('Available Commands:'))
      _.each(groupNames, (groupName) => {
        this._pushGroups(groupName, commandsGroup[groupName], maxWidth, kleur, strings)
      })
    }

    kleur.enabled = true
    strings.push(WHITE_SPACE)
    return strings.join('\n')
  }
}