private static @Nullable Path computeLogDirPath(Path baseLogDir, int directoryCounter) {
    String namePrefix = DateTimeFormatter.ofPattern("yyyy-MM-dd_'at'_HH-mm-ss").format(LocalDateTime.now());
    String nameSuffix = directoryCounter > 0 ? "_" + directoryCounter : "";
    Path logPath = baseLogDir.resolve(namePrefix + nameSuffix);
    if (!Files.exists(logPath)) {
      return logPath;
    }
    
    /* since this process locks directoryCounter, the log directory with the suggested name may exist only if it was left by the previous 
       process, so let's choose a different name */
    for (int i = 1; i < 1000; i++) {
      Path newLogPath = baseLogDir.resolve(String.format("%s-%03d%s", namePrefix, i, nameSuffix));
      if (!Files.exists(newLogPath)) {
        return newLogPath;
      }
    }
    return null;
  }
private static @Nullable Path computeLogDirPath(Path baseLogDir, int directoryCounter)