How to use logplease - 10 common examples

To help you get started, we’ve selected a few logplease 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 orbitdb / orbit-db-cli / src / exit-on-error.js View on Github external
const Logger = require('logplease')
Logger.setLogLevel('NONE') // turn off logs

const logger = Logger.create('orbitdb-cli', { color: Logger.Colors.Cyan })

module.exports = (e, displayErrorMessage = true) => {
  if (displayErrorMessage) {
    console.error('Error:', e.message)
    logger.error(e.stack)
  } else {
    console.error(e.message)
  }
  process.exit(1)
}
github orbitdb / orbit-db-cli / src / exit-on-error.js View on Github external
const Logger = require('logplease')
Logger.setLogLevel('NONE') // turn off logs

const logger = Logger.create('orbitdb-cli', { color: Logger.Colors.Cyan })

module.exports = (e, displayErrorMessage = true) => {
  if (displayErrorMessage) {
    console.error('Error:', e.message)
    logger.error(e.stack)
  } else {
    console.error(e.message)
  }
  process.exit(1)
}
github OriginProtocol / origin / infra / growth / src / util / tokenDistributor.js View on Github external
// A helper class to send OGN.
// Used by the payout pipeline.

const BigNumber = require('bignumber.js')
const Logger = require('logplease')

const Token = require('@origin/token/src/token')

Logger.setLogLevel(process.env.LOG_LEVEL || 'INFO')
const logger = Logger.create('tokenDistributor')

// Number of block confirmations required for a transfer to be consider completed.
const NumBlockConfirmation = 3

// Wait up to 10 min for a transaction to get confirmed
const ConfirmationTimeoutSec = 10 * 60

class TokenDistributor {
  // Note: we can't use a constructor due to the async call to defaultAccount.
  async init(networkId, gasPriceMultiplier) {
    this.networkId = networkId
    this.gasPriceMultiplier = gasPriceMultiplier
    this.token = new Token(networkId)
    this.supplier = await this.token.defaultAccount()
    this.web3 = this.token.web3
github derwish-pro / singlehub / app.js View on Github external
    "use strict";
    const emitter_1 = require("./public/js/emitter/emitter");
    /**
     * Created by Derwish (derwish.pro@gmail.com) on 04.07.2016.
     * License: http://www.gnu.org/licenses/gpl-3.0.txt
     */
    //source map for node typescript debug
    require('source-map-support').install();
    console.log("----------------------------- SingleHub -----------------------------");
    let config = require('./config.json');
    const server_1 = require('./modules/server/server');
    const container_1 = require('./public/nodes/container');
    //add app root dir to global
    const path = require('path');
    global.__rootdirname = path.resolve(__dirname);
    const log = require('logplease').create('app', { color: 2 });
    class App extends emitter_1.Emitter {
        constructor() {
            super();
            this.createServer();
            if (!config.firstRun)
                this.start();
            //this need for app. in other modules
            // setTimeout(this.lateConstructor.bind(this),100);
        }
        lateConstructor() {
            this.createServer();
            if (!config.firstRun)
                this.start();
        }
        start() {
            if (!this.rootContainer) {
github orbitdb / orbit-db-pubsub / src / ipfs-pubsub.js View on Github external
'use strict'

const pSeries = require('p-series')
const PeerMonitor = require('ipfs-pubsub-peer-monitor')

const Logger = require('logplease')
const logger = Logger.create("pubsub", { color: Logger.Colors.Yellow })
Logger.setLogLevel('ERROR')

const maxTopicsOpen = 256
let topicsOpenCount = 0

class IPFSPubsub {
  constructor(ipfs, id) {
    this._ipfs = ipfs
    this._id = id
    this._subscriptions = {}

    if (this._ipfs.pubsub === null)
      logger.error("The provided version of ipfs doesn't have pubsub support. Messages will not be exchanged.")

    this._handleMessage = this._handleMessage.bind(this)

    // Bump up the number of listeners we can have open,
github OriginProtocol / origin / infra / growth / src / scripts / updateCampaigns.js View on Github external
// Runs periodically and scans active campaigns to update:
//  - capUsed: budget used so far.
//  - rewardStatus: set to ReadyForCalculation once campaign is over and
//    all events during the campaign time window have been verified.

'use strict'

const Logger = require('logplease')
const Sequelize = require('sequelize')

const enums = require('../enums')
const db = require('../models')
const parseArgv = require('../util/args')

Logger.setLogLevel(process.env.LOG_LEVEL || 'INFO')
const logger = Logger.create('verifyEvents', { showTimestamp: false })

class UpdateCampaigns {
  constructor(config) {
    this.config = config
    this.stats = {
      numProcessed: 0,
      numStatusReady: 0,
      numUsedCapUpdated: 0
    }
  }

  // TODO(franck): IMPLEMENT ME
  async _updateCapUsed(campaign) {
    logger.debug(`Checking capUsed for campaign ${campaign.id}`)
    return 0
github dreamnettech / dreamtime / src / electron / src / modules / tools / power.js View on Github external
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License 3.0 as published by
// the Free Software Foundation. See 
//
// Written by Ivan Bravo Bravo , 2019.

import { isNil } from 'lodash'
import { spawn } from 'child_process'
import EventBus from 'js-event-bus'
import deferred from 'deferred'
import semverRegex from 'semver-regex'
import { existsSync } from './fs'
import { getPowerPath } from './paths'
import { settings } from '../services'

const logger = require('logplease').create('electron:power')

export function exec(args, options = {}) {
  args.push('--debug')

  if (settings.processing.usePython) {
    // python script
    args.unshift('main.py')

    logger.debug('Spawning Python script.', {
      args,
      options,
    })

    return spawn('python3', args, {
      cwd: getPowerPath(),
      ...options,
github derwish-pro / singlehub / src / nodes / node.ts View on Github external
/**
 * Created by Derwish (derwish.pro@gmail.com) on 04.07.2016.
 * License: http://www.gnu.org/licenses/gpl-3.0.txt
 */

import { Container, Side } from "./container";
import Utils from "./utils";
// import { Editor } from "../js/editor/editor";
// import { Renderer } from "../js/editor/renderer";



const log = require('logplease').create('node', { color: 5 });



export interface IInputInfo {
    input: NodeInput;
    slot: number;
    link_pos: [number, number];
    locked: boolean;
}

export interface IOutputInfo {
    output: NodeOutput;
    slot: number;
    link_pos: [number, number];
    locked: boolean;
}
github orbitdb / orbit-db-cli / src / commands / create.js View on Github external
'use strict'

const Logger = require('logplease')
Logger.setLogLevel('NONE') // turn off logs
const logger = Logger.create('orbitdb-cli-create', { color: Logger.Colors.Green })

const createDatabase = require('../lib/create-database')
const outputTimer = require('../lib/output-timer')

const types = ['eventlog', 'feed', 'docstore', 'keyvalue', 'counter']

exports.command = `create  `
exports.aliases = 'new'
exports.desc = `Create a new database. Type can be one of: ${types.join('|')}`

exports.builder = (yargs) => {
  return yargs
    .usage(`Usage: $0 create  <${types.join('|')}>`)
    .example('\n$0 create /posts docstore',
             '\nCreate a document database called \'/posts\'')
github orbitdb / orbit-db-cli / src / commands / drop.js View on Github external
'use strict'

const rmrf = require('rimraf')
const path = require('path')

const Logger = require('logplease')
Logger.setLogLevel('NONE') // turn off logs
const logger = Logger.create('orbitdb-cli-drop', { color: Logger.Colors.Orange })

const openDatabase = require('../lib/open-database')
const outputTimer = require('../lib/output-timer')
const exitOnError = require('../exit-on-error')

/* Export as Yargs command */
exports.command = 'drop  yes'
exports.aliases = ['destroy']
exports.desc = 'Remove a database locally. This doesn\'t remove data on other nodes that have the removed database replicated.'

exports.builder = (yargs) => {
  return yargs
    .usage(`Usage: $0 drop  yes`)
}

logplease

Simple Javascript logger for Node.js and Browsers

MIT
Latest version published 6 years ago

Package Health Score

50 / 100
Full package analysis

Popular logplease functions