Ejemplo n.º 1
0
// display a message in the command line
function log(type = 'message', message, verbose = false) {
    switch (type) {
        case 'app':
            console.log(chalk.bgRgb(230, 20, 20)(`  ${ message }  `));
            break;
        case 'dump':
            if (verbose) {
                console.log(chalk.magenta.bold(`📦 ${ JSON.stringify(message, null, 2) }`));
            }
            break;
        case 'running':
            console.log(chalk.green.bold(`💻 ${ chalk.green(message) }`));
            break;
        case 'title':
            console.log(chalk.blue.bold(`🛠 ${ message }`));
            break;
        case 'verbose':
            if (verbose) {
                console.log(chalk.keyword('orange')(`🕵 ${ message }`));
            }
            break;
        case 'warn':
            console.warn(chalk.red.bold(`🚧 ${ message }`));
            break;
        default:
            console.log(message);
    }
}
Ejemplo n.º 2
0
	sharedbDoc.on('op', (ops, source) => {
		// Ignore our own ops.
		if (source) return;

		console.log(chalk.keyword('orange')('⬇'), shorten(ops));
		changeHandler(sharedbDoc.data, ops);
	});
Ejemplo n.º 3
0
import * as path from 'path';
import * as _ from 'lodash';
import * as nodeUuid from 'uuid';
import * as chalk from 'chalk';

import Collection from './core/collection';
import Tyr from './tyr';

const clr = chalk.hex('#cc5500'),
  clrMig = chalk.hex('#cc0055'),
  clrDesc = chalk.hex('#000000'),
  clrRed = chalk.keyword('red'),
  clrGreen = chalk.keyword('green'),
  clrYellow = chalk.hex('#aaaa00');

const MigrationStatus = new Collection({
  id: '_m1',
  name: 'tyrMigrationStatus',
  internal: true,
  fields: {
    _id: { is: 'string' },
    appliedOn: { is: 'date' },
    uuid: { is: 'string' }
  }
});

const doRemoveLock = async remove => {
  if (remove) {
    await MigrationStatus.db.deleteOne({ _id: '$$MIGRATION-LOCK' });
    log({ note: 'End Migration', end: true });
  }
Ejemplo n.º 4
0
// A simple logger wrapper for NodeJS
// https://github.com/ashthespy

const chalk = require('chalk');
const util = require('util');

// Template for a pretty console
const template = {
  log: chalk.bold.white,
  debug: chalk.bold.cyan,
  info: chalk.blue,
  error: chalk.bold.red,
  warn: chalk.keyword('orange'),
  cmd: chalk.green,
  var: chalk.bold.underline.cyanBright,
  evnt: chalk.bold.green,
  state: chalk.bold.cyanBright
};

const prettyLog = (chalkFnc, args) => {
  console.log(chalk.green('[SpotifyConnect]'),
    chalkFnc(...args.map((x) => {
      if (x instanceof Error) { return x.stack || x.message; } else if (typeof x === 'string') { return x; } else {
        return util.inspect(x, {
          showHidden: true,
          depth: null
        });
      }
    }))
  );
};