code: function create(filePath, maxSize, cb) {
    createStream(filePath, onHaveStream);
  
    function onHaveStream(err, stream, size) {
      if (err) return cb(err);
      var pending = null;
      var log = new EventEmitter();
      stream.on('error', function(err) {
        log.emit('error', err);
      });
      log.write = logWrite;
      cb(null, log);
      function logWrite(str) {
        var flushed = stream.write(str);
        size += str.length;
        if (pending === 'flush') {
          if (flushed) {
            pending = null;
          } else {
            stream.once('drain', function() {
              pending = null;
            });
          }
        }
        if (pending == null && size >= maxSize) {
          pending = 'rename';
          var archiveName = getArchiveName(filePath);
          fs.rename(filePath, archiveName, function(err){
            if (err) return log.emit('error', err);
            createStream(filePath, function(err, newStream, newSize){
              if (err) return log.emit('error', err);
              stream.once('close', function() {
                var gzip = zlib.createGzip();
                var inp = fs.createReadStream(archiveName);
                var out = fs.createWriteStream(archiveName + ".gz");
                inp.on('error', function(err) {
                  return log.emit('error', err);
                });
                out.on('error', function(err){
                  return log.emit('error', err);
                });
                inp.pipe(gzip).pipe(out);
                out.once('close', function(){
                  fs.unlink(archiveName, function(err){
                    if (err) return log.emit('error', err);
                  });
                });
              });
              stream.end();
              newStream.on('error', function(err) {
                return log.emit('error', err);
              });
              size = newSize;
              stream = newStream;
              pending = 'flush';
            });
          });
        }
      }
    }
  }
docs: cb(err, log) log.write(str, cb) cb(err)