code: async function removeExpiredLogFiles(logdir, maxDays, logger) {
    // ignore not exists dir
    const exists = await fs.exists(logdir);
    if (!exists) return;
  
    const files = await fs.readdir(logdir);
    const expriedDate = moment().subtract(maxDays, 'days').startOf('date');
    const names = files.filter(file => {
      const name = path.extname(file).substring(1);
      if (!/^\d{4}\-\d{2}\-\d{2}/.test(name)) {
        return false;
      }
      const date = moment(name, 'YYYY-MM-DD').startOf('date');
      if (!date.isValid()) {
        return false;
      }
      return date.isBefore(expriedDate);
    });
    if (names.length === 0) {
      return;
    }
  
    logger.info(`[egg-logrotator] start remove ${logdir} files: ${names.join(', ')}`);
  
    await Promise.all(names.map(name => {
      const logfile = path.join(logdir, name);
      return fs.unlink(logfile)
        .catch(err => {
          err.message = `[egg-logrotator] remove logfile ${logfile} error, ${err.message}`;
          logger.error(err);
        });
    }));
  }
docs: remove expired log files: xxx.log.YYYY-MM-DD