How to use the logplease.setLogLevel function in logplease

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 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 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 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`)
}
github orbitdb / orbit-db-cli / src / commands / get.js View on Github external
'use strict'

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

const Logger = require('logplease')
Logger.setLogLevel('NONE') // turn off logs
const logger = Logger.create('get', { color: Logger.Colors.Magenta })

/* Export as Yargs command */
exports.command = 'get  []'
exports.aliases = ['query', 'search']
exports.desc = 'Query the database.\n'

exports.builder = (yargs) => {
  return yargs
    .usage('This command is used to query a database in orbit-db.\n' +
           '\nUsage: $0 get|search|query  []')
    .example('\n$0 get /posts',
             '\nQuery all results from /posts when /posts is an eventlog')
    .example('\n$0 get /posts --limit 1',
             '\nQuery the latest event from /posts when /posts is an eventlog')
    .example('\n$0 search /users QmFoo1',
github OriginProtocol / origin / origin-dapp-creator-server / src / logger.js View on Github external
'use strict'

const Logger = require('logplease')
Logger.setLogLevel('DEBUG')
module.exports = Logger.create('origin-dapp-creator-server', {
  color: Logger.Colors.Green
})
github OriginProtocol / origin / origin-ipfs-proxy / src / logger.js View on Github external
'use strict'

const Logger = require('logplease')

Logger.setLogLevel('DEBUG')

module.exports = Logger.create('origin-ipfs-proxy', {
  color: Logger.Colors.Yellow
})
github OriginProtocol / origin / origin-messaging / src / logger.js View on Github external
'use strict'

const Logger = require('logplease')
Logger.setLogLevel('DEBUG')
module.exports = Logger.create('origin-messaging', {
  color: Logger.Colors.Yellow
})

logplease

Simple Javascript logger for Node.js and Browsers

MIT
Latest version published 6 years ago

Package Health Score

48 / 100
Full package analysis

Popular logplease functions