diff options
author | 2017-08-08 14:02:53 +0800 | |
---|---|---|
committer | 2017-08-08 14:02:53 +0800 | |
commit | c0604184b2aa8cff924ca783ec6b36f1f5988775 (patch) | |
tree | 1c70ffe1ad90c915b3382a37eb2fa80901519c7b /wso2/logging-sdk/src/main/java/org/openo/log/api/LogMessage.java | |
parent | 706fc9fed496972968fde136c3e4e10f9578a5b3 (diff) |
init code
Change-Id: Icd0948118397b256da70dfbcbbec5520dc5eafd4
Signed-off-by: Zhaoxing <meng.zhaoxing1@zte.com.cn>
Diffstat (limited to 'wso2/logging-sdk/src/main/java/org/openo/log/api/LogMessage.java')
-rw-r--r-- | wso2/logging-sdk/src/main/java/org/openo/log/api/LogMessage.java | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/wso2/logging-sdk/src/main/java/org/openo/log/api/LogMessage.java b/wso2/logging-sdk/src/main/java/org/openo/log/api/LogMessage.java new file mode 100644 index 0000000..4a21584 --- /dev/null +++ b/wso2/logging-sdk/src/main/java/org/openo/log/api/LogMessage.java @@ -0,0 +1,132 @@ +/** + * Copyright 2017 ZTE Corporation. + * + * 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 org.openo.log.api; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import org.slf4j.Logger; + +import org.openo.log.impl.Facitility; +import org.slf4j.LoggerFactory; + + +/** + * + * @author Huabing Zhao + * + */ + +public class LogMessage implements Serializable { + private static final Logger LOGGER = LoggerFactory.getLogger(LogMessage.class.getName()); + + protected long id = -1; + + + protected String detail = null; + + protected String hostname = ""; + + + + private String logType = ""; + + + protected HashMap<String, Object> extendedFields = null; + + private HashMap<String, String> localeMap = null; + + + + private static final long serialVersionUID = 200408041651009L; + + public String getDetail() { + return detail; + } + + + public long getId() { + return id; + } + + public String getHostname() { + return hostname; + } + + + + public LogMessage() {} + + + + public String getLogType() { + return logType; + } + + public void setLogType(String logType) { + this.logType = logType; + } + + public HashMap<String, Object> getExtendedFields() { + return extendedFields; + } + + public void setExtendedFields(HashMap<String, Object> extendedFields) { + this.extendedFields = extendedFields; + } + + public HashMap<String, String> getLocaleMap() { + return this.localeMap; + } + + public void setLocalMap(HashMap<String, String> localeMap) { + this.localeMap = localeMap; + } + + protected void set(String condName, Object condValue) { + if (condValue != null && !"".equals(condValue)) { + if (localeMap == null) { + localeMap = new HashMap<String, String>(); + } + localeMap.put(condName, condValue.toString()); + + } + } + + + protected void setLocale(String condName, String condValue) { + + if (condValue != null && !"".equals(condValue)) { + if (localeMap == null) { + localeMap = new HashMap<String, String>(); + } + + + + Map<String, String> mapJson = Facitility.readJson2Map(condValue); + for (Entry<String, String> entry : mapJson.entrySet()) { + String key = entry.getKey(); + + String value = entry.getValue().replace("\"", "\'"); + localeMap.put(condName + "_" + key, value); + } + } + + } + + +} |