當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript npmlog.info函數代碼示例

本文整理匯總了TypeScript中npmlog.info函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript info函數的具體用法?TypeScript info怎麽用?TypeScript info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了info函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

 socket.on('connect', () => {
   log.info('Connected to ' + this.getConnectionInfo());
   socket.emit(
     'room',
     '/' + this.coin.toUpperCase() + '/' + this.v8network + '/inv'
   );
 });
開發者ID:bitpay,項目名稱:bitcore,代碼行數:7,代碼來源:v8.ts

示例2:

    const returnError = (err, res, req) => {
      if (err instanceof ClientError) {
        const status = err.code == 'NOT_AUTHORIZED' ? 401 : 400;
        if (!opts.disableLogs)
          log.info(
            'Client Err: ' + status + ' ' + req.url + ' ' + JSON.stringify(err)
          );

        res
          .status(status)
          .json({
            code: err.code,
            message: err.message
          })
          .end();
      } else {
        let code = 500,
          message;
        if (err && ((err.code && _.isNumber(err.code)) || (err.statusCode && _.isNumber(err.statusCode)))) {
          code = err.code || err.statusCode;
          message = err.message || err.body;
        }

        const m = message || err.toString();

        if (!opts.disableLogs) log.error(req.url + ' :' + code + ':' + m);

        res
          .status(code || 500)
          .json({
            error: m
          })
          .end();
      }
    };
開發者ID:matiu,項目名稱:bitcore,代碼行數:35,代碼來源:expressapp.ts

示例3: cb

 (err, db) => {
   if (err) {
     log.error('Unable to connect to the mongoDB', err);
     return cb(err, null);
   }
   log.info('Connection established to ' + uri);
   this.db = db;
   this._getStats((err, stats) => {
     if (err) return cb(err);
     return cb(null, stats);
   });
 }
開發者ID:bitpay,項目名稱:bitcore,代碼行數:12,代碼來源:stats.ts

示例4: test

test('request', (t) => {
  t.plan(1);
  npmlog.level = 'silly';
  npmlog.silly('silly prefix', 'x = %j', {foo:{bar:'baz'}});
  npmlog.verbose('verbose prefix', 'x = %j', {foo:{bar:'baz'}});
  npmlog.info('info prefix', 'x = %j', {foo:{bar:'baz'}});
  npmlog.http('http prefix', 'x = %j', {foo:{bar:'baz'}});
  npmlog.warn('warn prefix', 'x = %j', {foo:{bar:'baz'}});
  npmlog.error('error prefix', 'x = %j', {foo:{bar:'baz'}});
  npmlog.silent('silent prefix', 'x = %j', {foo:{bar:'baz'}});

  t.deepEqual(result.join('').trim(), resultExpect.join('').trim(), 'result');
});
開發者ID:demurgos,項目名稱:typed-npmlog,代碼行數:13,代碼來源:test.ts

示例5:

  expressApp.start(config, (err) => {
    if (err) {
      log.error('Could not start BWS instance', err);
      return;
    }

    server.listen(port);

    const instanceInfo = cluster.worker
      ? ' [Instance:' + cluster.worker.id + ']'
      : '';
    log.info('BWS running ' + instanceInfo);
    return;
  });
開發者ID:bitpay,項目名稱:bitcore,代碼行數:14,代碼來源:bws.ts

示例6: icb

          .then(ret => {
            try {
              ret = JSON.parse(ret);

              // only process right responses.
              if (!_.isUndefined(ret.blocks) && ret.blocks != x) {
                log.info(`Ignoring response for ${x}:` + JSON.stringify(ret));
                return icb();
              }

              result[x] = ret.feerate;
            } catch (e) {
              log.warn('fee error:', e);
            }

            return icb();
          })
開發者ID:bitpay,項目名稱:bitcore,代碼行數:17,代碼來源:v8.ts

示例7: initSocket

  initSocket(callbacks) {
    log.info('V8 connecting socket at:' + this.host);
    // sockets always use the first server on the pull
    const socket = io.connect(
      this.host,
      { transports: ['websocket'] }
    );

    socket.on('connect', () => {
      log.info('Connected to ' + this.getConnectionInfo());
      socket.emit(
        'room',
        '/' + this.coin.toUpperCase() + '/' + this.v8network + '/inv'
      );
    });

    socket.on('connect_error', () => {
      log.error('Error connecting to ' + this.getConnectionInfo());
    });
    socket.on('tx', callbacks.onTx);
    socket.on('block', (data) => {
      return callbacks.onBlock(data.hash);
    });
    socket.on('coin', data => {
      // script output, or similar.
      if (!data.address) return;
      let out;
      try {
        // TODO
        out = {
          address: data.address,
          amount: data.value / 1e8
        };
      } catch (e) {
        // non parsable address
        return;
      }
      return callbacks.onIncomingPayments({ outs: [out], txid: data.mintTxid });
    });

    return socket;
  }
開發者ID:bitpay,項目名稱:bitcore,代碼行數:42,代碼來源:v8.ts

示例8:

  client.on('ready', () => {
    log.info('play', 'connected');

    client.exec(monogataris.tasks[0].shell, (err, stream) => {
      if(err) {
        throw err;
      }

      stream.on('close', (code, signal) => {
        log.info('play', `end code:${code}, signal:${signal}`);
        client.end();
      })
      .on('data', data => {
        log.info('play', data);
      })
      .stderr.on('data', data => {
        log.error('play', data);
      });

    });
  })
開發者ID:waffle-iron,項目名稱:shikibu,代碼行數:21,代碼來源:play.ts

示例9: constructor

  constructor(opts) {
    super();

    opts = opts || {};
    if (opts.messageBrokerServer) {
      const url = opts.messageBrokerServer.url;

      this.remote = true;
      this.mq = require('socket.io-client').connect(url);
      this.mq.on('connect', () => { });
      this.mq.on('connect_error', () => {
        log.warn('Error connecting to message broker server @ ' + url);
      });

      this.mq.on('msg', (data) => {
        this.emit('msg', data);
      });

      log.info('Using message broker server at ' + url);
    }
  }
開發者ID:bitpay,項目名稱:bitcore,代碼行數:21,代碼來源:messagebroker.ts

示例10: start

  /**
   * start
   *
   * @param opts.WalletService options for WalletService class
   * @param opts.basePath
   * @param opts.disableLogs
   * @param opts.doNotCheckV8
   * @param {Callback} cb
   */
  start(opts, cb) {
    opts = opts || {};

    this.app.use(compression());

    this.app.use((req, res, next) => {
      res.setHeader('Access-Control-Allow-Origin', '*');
      res.setHeader(
        'Access-Control-Allow-Methods',
        'GET, POST, OPTIONS, PUT, DELETE'
      );
      res.setHeader(
        'Access-Control-Allow-Headers',
        'x-signature,x-identity,x-session,x-client-version,x-wallet-id,X-Requested-With,Content-Type,Authorization'
      );
      res.setHeader('x-service-version', WalletService.getServiceVersion());
      next();
    });
    const allowCORS = (req, res, next) => {
      if ('OPTIONS' == req.method) {
        res.sendStatus(200);
        res.end();
        return;
      }
      next();
    };
    this.app.use(allowCORS);
    this.app.enable('trust proxy');

    // handle `abort` https://nodejs.org/api/http.html#http_event_abort
    this.app.use((req, res, next) => {
      req.on('abort', () => {
        log.warn('Request aborted by the client');
      });
      next();
    });

    const POST_LIMIT = 1024 * 100 /* Max POST 100 kb */;

    this.app.use(
      bodyParser.json({
        limit: POST_LIMIT
      })
    );

    if (opts.disableLogs) {
      log.level = 'silent';
    } else {
      const morgan = require('morgan');
      morgan.token('walletId', function getId(req) {
        return req.walletId ? '<' + req.walletId + '>' : '<>';
      });

      const logFormat =
        ':walletId :remote-addr :date[iso] ":method :url" :status :res[content-length] :response-time ":user-agent"  ';
      const logOpts = {
        skip(req, res) {
          if (res.statusCode != 200) return false;
          return req.path.indexOf('/notifications/') >= 0;
        }
      };
      this.app.use(morgan(logFormat, logOpts));
    }

    const router = express.Router();

    const returnError = (err, res, req) => {
      if (err instanceof ClientError) {
        const status = err.code == 'NOT_AUTHORIZED' ? 401 : 400;
        if (!opts.disableLogs)
          log.info(
            'Client Err: ' + status + ' ' + req.url + ' ' + JSON.stringify(err)
          );

        res
          .status(status)
          .json({
            code: err.code,
            message: err.message
          })
          .end();
      } else {
        let code = 500,
          message;
        if (err && ((err.code && _.isNumber(err.code)) || (err.statusCode && _.isNumber(err.statusCode)))) {
          code = err.code || err.statusCode;
          message = err.message || err.body;
        }

        const m = message || err.toString();

//.........這裏部分代碼省略.........
開發者ID:matiu,項目名稱:bitcore,代碼行數:101,代碼來源:expressapp.ts


注:本文中的npmlog.info函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。