code: function ensureLogDir(dir) {
      if (!dir) return;
      let mkdir = true;
      try {
          const stat = fs.statSync(dir);
          if (stat && !stat.isDirectory()) {
              mkdir = false;
              throw new Error(`'logDir' must be a directory`);
          }
      } catch (e) {
          if (mkdir) {
              fs.mkdirSync(dir);
          }
      }
  }
docs: 确保日志目录存在
  @param dir