How to use logger - 10 common examples

To help you get started, we’ve selected a few logger 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 WPO-Foundation / webpagetest / agent / js / src / agent_main.js View on Github external
// Nuke any non-webdriver scripts for now.  Regular WPT
        // scripts would have been pre-processed when the task was
        // initially parsed.
        script = undefined;
      }
      url = url.trim();
      if (!((/^https?:\/\//i).test(url))) {
        url = 'http://' + url;
      }
    } catch (e) {
      job.testError = e.message;
      this.abortJob_(job);
      return;
    }

    logger.info('%s run %d%s/%d of job %s',
        (job.retryError ? 'Retrying' : 'Starting'), job.runNumber,
        (job.isFirstViewOnly ? '' : (job.isCacheWarm ? 'b' : 'a')),
        job.runs, job.id);

    if (this.wdServer_ && !job.isCacheWarm) {
      if (!job.retryError) {
        throw new Error('Internal error: unclean non-retry first view');
      }
      logger.debug('Cleaning before repeat first-view');
      this.scheduleCleanup_(job, /*isEndOfJob=*/false);
    }
    this.scheduleCleanRunTempDir_();

    if (this.isTrafficShaping_(job)) {
      this.startTrafficShaper_(job);  // Start shaping.
    } else {
github WPO-Foundation / webpagetest / agent / js / src / adb.js View on Github external
function(stdout) {
        var resolvedPath = stdout.trim(); // remove newline.
        if (!resolvedPath) {
          return tryRemainingPaths(pathsToTry);
        }
        logger.debug('Found storage path %s --> %s', path, resolvedPath);
        // Return the resolved path (e.g. '/sdcard' not '$EXTERNAL_STORAGE'),
        // so the caller can `adb push/pull` files to the absolute path.
        this.storagePath_ = resolvedPath;
        return resolvedPath;
      }.bind(this));
    }.bind(this));
github WPO-Foundation / webpagetest / agent / js / src / agent_main.js View on Github external
process_utils.scheduleGetAll(this.app_).then(function(processInfos) {
      var pid = process.pid;
      var pi; // Declare outside the loop, to avoid a jshint warning
      while (pid) {
        pi = undefined;
        for (var i = 0; i < processInfos.length; ++i) {
          if (processInfos[i].pid === pid) {
            pi = processInfos.splice(i, 1)[0];
            logger.debug('Not killing user %s pid=%s: %s %s', process.env.USER,
                pid, pi.command, pi.args.join(' '));
            break;
          }
        }
        pid = (pi ? pi.ppid : undefined);
      }
      if (processInfos.length > 0) {
        logger.info('Killing %s pids owned by user %s: %s', processInfos.length,
            process.env.USER,
            processInfos.map(function(pi) { return pi.pid; }).join(', '));
        process_utils.scheduleKillAll(
            this.app_, 'Kill dangling pids', processInfos);
      }
    }.bind(this), function(e) {
      logger.error('Unable to killall pids: ' + e.message);
github WPO-Foundation / webpagetest / agent / js / src / process_utils.js View on Github external
return app.schedule(cmd, function() {
    logger.debug('Exec with timeout(%d): %s', timeout, cmd);

    // Create output buffers
    var stdout = '';
    var stderr = '';
    function newMsg(desc, code, signal) {
      function crop(s, n) {
        return (s.length <= n ? s : s.substring(0, n - 3) + '...');
      }
      var ret = [desc, code && 'code ' + code, signal && 'signal ' + signal,
          stdout && 'stdout[' + stdout.length + '] ' + crop(stdout, 1024),
          stderr && 'stderr[' + stderr.length + '] ' + crop(stderr, 1024)];
      // Comma-separated elements of ret, except the undefined ones.
      return ret.filter(function(v) { return !!v; }).join(', ');
    }
    function newError(desc, code, signal) {
      var ret = new Error(newMsg(desc, code, signal));
github WPO-Foundation / webpagetest / agent / js / src / agent_main.js View on Github external
var pid = process.pid;
      var pi; // Declare outside the loop, to avoid a jshint warning
      while (pid) {
        pi = undefined;
        for (var i = 0; i < processInfos.length; ++i) {
          if (processInfos[i].pid === pid) {
            pi = processInfos.splice(i, 1)[0];
            logger.debug('Not killing user %s pid=%s: %s %s', process.env.USER,
                pid, pi.command, pi.args.join(' '));
            break;
          }
        }
        pid = (pi ? pi.ppid : undefined);
      }
      if (processInfos.length > 0) {
        logger.info('Killing %s pids owned by user %s: %s', processInfos.length,
            process.env.USER,
            processInfos.map(function(pi) { return pi.pid; }).join(', '));
        process_utils.scheduleKillAll(
            this.app_, 'Kill dangling pids', processInfos);
      }
    }.bind(this), function(e) {
      logger.error('Unable to killall pids: ' + e.message);
github WPO-Foundation / webpagetest / agent / js / src / process_utils.js View on Github external
var timerId = global.setTimeout(function() {
      timerId = undefined;  // Reset it before the close listener gets called.
      try {
        proc.kill();
      } catch (e) {
        logger.error('Error killing %s: %s', cmd, e);
      }
      // The kill() call normally triggers the close listener, but we reject
      // the promise here instead of the close listener, because we don't really
      // know if and when it's going to be killed at OS level.
      // In the future we may want to restart the adb server here as a recovery
      // for wedged adb connections, or use a relay board for device recovery.
      done.reject(
          newError(cmd + ' timeout after ' + (timeout / 1000) + ' seconds'));
    }, timeout);
github paralect / koa-api-starter / src / app.js View on Github external
process.on('unhandledRejection', (reason, p) => {
  logger.error('Possibly Unhandled Rejection at: Promise ', p, ' reason: ', reason);
  // application specific logging here
});
github WPO-Foundation / webpagetest / agent / js / src / browser_base.js View on Github external
proc.on('exit', function(code, signal) {
      logger.info(name + ' EXIT code %s signal %s', code, signal);
      this.childProcess_ = undefined;
      this.onChildProcessExit();
    }.bind(this));
  }.bind(this));
github WPO-Foundation / webpagetest / agent / js / src / wd_server.js View on Github external
exports.process.on('message', function(message) {
    var cmd = (message ? message.cmd : '');
    if ('run' === cmd) {
      this.init(message);
      this.connect();
    } else if ('abort' === cmd) {
      this.agentErrror_ = this.agentError_ || (new Error('abort'));
      this.done_();
    } else {
      logger.error('Unrecognized IPC command %s, message: %j', cmd, message);
    }
  }.bind(this));
};
github WPO-Foundation / webpagetest / agent / js / src / wd_server.js View on Github external
WebDriverServer.prototype.saveScreenshot_ = function(
    fileName, screenshot, description) {
  'use strict';
  logger.debug('Saving screenshot %s (%d bytes): %s',
      fileName, screenshot.length, description);
  var diskPath = path.join(this.runTempDir_, fileName);
  return process_utils.scheduleFunction(this.app_,
      'Write screenshot file ' + diskPath,
      fs.writeFile, diskPath, screenshot).then(function() {
    return this.addScreenshot_(fileName, diskPath, description);
  }.bind(this));
};

logger

A simple logging library that combines the simple APIs of Ruby's logger.rb and browser-js console.log()

Unknown
Latest version published 10 years ago

Package Health Score

39 / 100
Full package analysis

Popular logger functions