lib/stack.js
function Stack(name, dreadnot, config) {
  var self = this,
      logName = sprintf('deploy.stack.%s', name),
      sinkName = sprintf('stack.%s', name),
      moduleName;

  if (config.stacks[name].hasOwnProperty('module_name')) {
    moduleName = config.stacks[name].module_name;
  }
  else {
    moduleName = name;
  }

  this.name = name;
  this.dreadnot = dreadnot;
  this.module = require(path.join(path.resolve(dreadnot.stackdir), moduleName));
  this.config = config;
  this.stackConfig = config.stacks[name];
  this.log = logmagic.local(logName);
  this.logRoot = path.join(config.data_root, 'logs', name);
  this.newestDeployments = {};
  this.repo = this.stackConfig.repo || name;
  this.current = null;
  this._cache = {};
  this._waiting = {};

  logmagic.registerSink(sinkName, function(moduleName, lvl, msg, obj) {
    var both = moduleName.split('.').slice(-2),
        logPath = ['regions', both[0], 'deployments', both[1], 'log'].join('.');

    // Fix serialization of Error objects
    if (obj.err && obj.err instanceof Error) {
      obj.err = {
        name: obj.err.name,
        message: obj.err.message,
        stack: obj.err.stack
      };
    }

    self.emit(logPath, {
      lvl: lvl,
      msg: msg,
      obj: obj
    });
  });
  logmagic.route(sprintf('%s.*', logName), logmagic.INFO, sinkName);
}
function Stack(name, dreadnot, config) {
  var self = this,
      logName = sprintf('deploy.stack.%s', name),
      sinkName = sprintf('stack.%s', name),
      moduleName;

  if (config.stacks[name].hasOwnProperty('module_name')) {
    moduleName = config.stacks[name].module_name;
  }
  else {
    moduleName = name;
  }

  this.name = name;
  this.dreadnot = dreadnot;
  this.module = require(path.join(path.resolve(dreadnot.stackdir), moduleName));
  this.config = config;
  this.stackConfig = config.stacks[name];
  this.log = logmagic.local(logName);
  this.logRoot = path.join(config.data_root, 'logs', name);
  this.newestDeployments = {};
  this.repo = this.stackConfig.repo || name;
  this.current = null;
  this._cache = {};
  this._waiting = {};

  logmagic.registerSink(sinkName, function(moduleName, lvl, msg, obj) {
    var both = moduleName.split('.').slice(-2),
        logPath = ['regions', both[0], 'deployments', both[1], 'log'].join('.');

    // Fix serialization of Error objects
    if (obj.err && obj.err instanceof Error) {
      obj.err = {
        name: obj.err.name,
        message: obj.err.message,
        stack: obj.err.stack
      };
    }

    self.emit(logPath, {
      lvl: lvl,
      msg: msg,
      obj: obj
    });
  });
  logmagic.route(sprintf('%s.*', logName), logmagic.INFO, sinkName);
}
Stack Constructor.
@constructor
@param {String} name The name of this stack.
@param {Object} config The global config.