code: function(maxLines) {
      var cbs = [];
      var lines = [];
      var current = null;
      var closed = false
      var max = maxLines - 1;
  
      function emit(line) {
        cbs.forEach(function(cb) { cb(line); });
      }
  
      return {
        callback: function(cb) {
          lines.forEach(function(l) { cb(l); });
          cbs.push(cb);
        },
  
        append: function(str) {
          if (closed) return;
          if (str instanceof Buffer) str = '' + str;
          if (!str || str.length === 0) return;
  
          var newLines = str.split(nlRegexp);
  
          if (newLines.length === 1) {
            if (current !== null) {
              current = current + newLines.shift();
            } else {
              current = newLines.shift();
            }
          } else {
            if (current !== null) {
              current = current + newLines.shift();
              emit(current);
              lines.push(current);
            }
  
            current = newLines.pop();
  
            newLines.forEach(function(l) {
              emit(l);
              lines.push(l);
            });
  
            if (max > -1 && lines.length > max) {
              lines.splice(0, lines.length - max);
            }
          }
        },
  
        get: function() {
          if (current !== null) {
            return lines.concat([current]).join('\n');
          } else {
            return lines.join('\n');
          }
        },
  
        close: function() {
          if (closed) return;
  
          if (current !== null) {
            emit(current);
            lines.push(current);
  
            if (max > -1 && lines.length > max) {
              lines.shift();
            }
  
            current = null;
          }
  
          closed = true;
        }
      };
    }
docs: Creates a line ring buffer object with the following methods:
  - append(str) : appends a string or buffer
  - get() : returns the whole string
  - close() : prevents further append() calls and does a last call to callbacks
  - callback(cb) : calls cb for each line (incl. those already in the ring)
  
  @param {Numebr} maxLines maximum number of lines to store (<= 0 for unlimited)