All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.undefinedlabs.scope.logger.FileScopeLoggerRootPathResolver Maven / Gradle / Ivy

package com.undefinedlabs.scope.logger;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import com.undefinedlabs.scope.settings.ScopeSettings;

public enum FileScopeLoggerRootPathResolver {
  INSTANCE;

  private static final String ROOT_PATH_WINDOWS = System.getenv("APPDATA") + "/scope/logs";
  private static final String ROOT_PATH_LINUX = "/var/log/scope";
  private static final String ROOT_PATH_MAC =
      System.getProperty("user.home") + "/Library/Logs/Scope";

  public String resolveRootPath(final ScopeSettings settings) {
    final String customLogPath = (String) settings.getSetting(ScopeSettings.SCOPE_LOGGER_ROOT);
    if (StringUtils.isNotEmpty(customLogPath)) {
      return customLogPath;
    }

    if (SystemUtils.IS_OS_WINDOWS) {
      return ROOT_PATH_WINDOWS;
    } else if (SystemUtils.IS_OS_LINUX) {
      return ROOT_PATH_LINUX;
    } else if (SystemUtils.IS_OS_MAC) {
      return ROOT_PATH_MAC;
    }

    return null;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy