[ISSUE #7229] Optimize the constants to the logging package for the client module. Part 2 (#7256)

* add Constants.java

* Optimize the constants to the logging package for the client module
This commit is contained in:
onewe 2021-11-24 11:16:09 +08:00 committed by GitHub
parent 33427e83bf
commit e4c5368147
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 4 deletions

View File

@ -0,0 +1,59 @@
/*
* Copyright 1999-2018 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.nacos.client.constant;
/**
* All the constants.
*
* @author onew
*/
public class Constants {
public static class SysEnv {
public static final String USER_HOME = "user.home";
public static final String PROJECT_NAME = "project.name";
public static final String JM_LOG_PATH = "JM.LOG.PATH";
public static final String JM_SNAPSHOT_PATH = "JM.SNAPSHOT.PATH";
}
public static class Disk {
public static final String READ_ONLY = "r";
public static final String READ_WRITE = "rw";
}
public static class HealthCheck {
public static final String UP = "UP";
public static final String DOWN = "DOWN";
}
public static class Protocols {
public static final String HTTP = "http://";
public static final String HTTPS = "https://";
}
}

View File

@ -16,6 +16,7 @@
package com.alibaba.nacos.client.logging; package com.alibaba.nacos.client.logging;
import com.alibaba.nacos.client.constant.Constants;
import com.alibaba.nacos.common.utils.ConvertUtils; import com.alibaba.nacos.common.utils.ConvertUtils;
import com.alibaba.nacos.common.utils.StringUtils; import com.alibaba.nacos.common.utils.StringUtils;
@ -33,13 +34,13 @@ public abstract class AbstractNacosLogging {
private static final String NACOS_LOGGING_DEFAULT_CONFIG_ENABLED_PROPERTY = "nacos.logging.default.config.enabled"; private static final String NACOS_LOGGING_DEFAULT_CONFIG_ENABLED_PROPERTY = "nacos.logging.default.config.enabled";
private static final String NACOS_LOGGING_PATH_PROPERTY = "JM.LOG.PATH"; private static final String NACOS_LOGGING_PATH_DIR = "logs";
static { static {
String loggingPath = System.getProperty(NACOS_LOGGING_PATH_PROPERTY); String loggingPath = System.getProperty(Constants.SysEnv.JM_LOG_PATH);
if (StringUtils.isBlank(loggingPath)) { if (StringUtils.isBlank(loggingPath)) {
String userHome = System.getProperty("user.home"); String userHome = System.getProperty(Constants.SysEnv.USER_HOME);
System.setProperty(NACOS_LOGGING_PATH_PROPERTY, userHome + File.separator + "logs"); System.setProperty(Constants.SysEnv.JM_LOG_PATH, userHome + File.separator + NACOS_LOGGING_PATH_DIR);
} }
} }