Skip to content

Commit

Permalink
[ISSUE alibaba#7229] Optimize the constants to the logging package fo…
Browse files Browse the repository at this point in the history
…r the client module. Part 2 (alibaba#7256)

* add Constants.java

* Optimize the constants to the logging package for the client module
  • Loading branch information
onewe authored Nov 24, 2021
1 parent 33427e8 commit e4c5368
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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://";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

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.StringUtils;

Expand All @@ -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_PATH_PROPERTY = "JM.LOG.PATH";
private static final String NACOS_LOGGING_PATH_DIR = "logs";

static {
String loggingPath = System.getProperty(NACOS_LOGGING_PATH_PROPERTY);
String loggingPath = System.getProperty(Constants.SysEnv.JM_LOG_PATH);
if (StringUtils.isBlank(loggingPath)) {
String userHome = System.getProperty("user.home");
System.setProperty(NACOS_LOGGING_PATH_PROPERTY, userHome + File.separator + "logs");
String userHome = System.getProperty(Constants.SysEnv.USER_HOME);
System.setProperty(Constants.SysEnv.JM_LOG_PATH, userHome + File.separator + NACOS_LOGGING_PATH_DIR);
}
}

Expand Down

0 comments on commit e4c5368

Please sign in to comment.