org.zodiac.sdk.log.global.Slite2LogPathInit Maven / Gradle / Ivy
The newest version!
package org.zodiac.sdk.log.global;
import org.zodiac.sdk.log.constants.LogConstants;
import org.zodiac.sdk.log.util.ReportUtil;
public class Slite2LogPathInit {
/***
* 在平台starter 的 ApplicationContextInitializer 要调用此函数做判断达到设置日志路径的目的:
*
*
* - 是否设置了全局路径参数
logging.path
。
* - 没有设置将设置路径
platformLoggingPath
。
*
*
*
* @param platformLoggingPath 中间件日志路径参数
*/
public static void initLoggingPath(String platformLoggingPath) {
if (isBlank((String) System.getProperties().get(LogConstants.LOG_PATH))
&& !isBlank(platformLoggingPath)) {
System.getProperties().put(LogConstants.LOG_PATH, platformLoggingPath);
ReportUtil.reportDebug("Actual " + LogConstants.LOG_PATH + " is [ " + platformLoggingPath + " ]");
}
}
private static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(str.charAt(i))) {
return false;
}
}
return true;
}
}