summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlice Liu <alice.liu@intel.com>2014-10-24 15:17:38 +0800
committerAlice Liu <alice.liu@intel.com>2014-10-24 16:19:52 +0800
commit25ddc57fe58151a2b143a7bddb0f300b10a5d408 (patch)
tree2621211364e7ee753bb8a0d42026158ee9c5d75c
parent5ebdf811a7802dbe53e50b94338f5b86a1920fcf (diff)
downloadcommon-eplugin-25ddc57fe58151a2b143a7bddb0f300b10a5d408.tar.gz
common-eplugin-25ddc57fe58151a2b143a7bddb0f300b10a5d408.tar.bz2
common-eplugin-25ddc57fe58151a2b143a7bddb0f300b10a5d408.zip
COMMON: Added journal dlog parser
Tizen3 started to user journal command to get system log. Added journal dlog parser. Change-Id: Id00568f185c91d6fd72f4d7502435c3aad5646d3 Signed-off-by: Alice Liu <alice.liu@intel.com>
-rw-r--r--org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogFormat.java3
-rw-r--r--org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogJournalParser.java76
-rw-r--r--org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogParserFactory.java2
-rw-r--r--org.tizen.common/src/org/tizen/common/TizenPlatformConstants.java3
4 files changed, 83 insertions, 1 deletions
diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogFormat.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogFormat.java
index 61e78ae30..fe05a969a 100644
--- a/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogFormat.java
+++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogFormat.java
@@ -38,7 +38,8 @@ public enum DlogFormat {
// RAW, //$NON-NLS-1$
// TIME, //$NON-NLS-1$
// THREADTIME, //$NON-NLS-1$
- LONG("long");
+ LONG("long"),
+ JOURNAL("");
String vOption;
diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogJournalParser.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogJournalParser.java
new file mode 100644
index 000000000..343264cc4
--- /dev/null
+++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogJournalParser.java
@@ -0,0 +1,76 @@
+/*
+* Common
+*
+* Copyright (c) 2014 Intel Corporation. All rights reserved.
+*
+* Contact:
+* Alice Liu <alice.liu@intel.com>
+*
+* 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.
+*
+* Contributors:
+* - Intel Corporation
+*
+*/
+package org.tizen.sdblib.dlog;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.tizen.sdblib.util.StringUtil;
+import org.tizen.sdblib.util.LogLevel;
+import org.tizen.sdblib.util.Log;
+
+/**
+ * The parser that is used when sdb execute journalctl option.
+ *
+ * @author Alice Liu {@literal <alice.liu@intel.com>} (Intel)
+ *
+ */
+public class DlogJournalParser implements IDlogParser {
+ /**
+ * log's format: <br>
+ * level/tag: message
+ */
+ private static final Pattern pattern = Pattern.compile("^\\[.*:(\\w+):(\\w+).*\\]\\s(.+)");
+
+ @Override
+ public DlogInfo[] parse(String... lines) {
+ List<DlogInfo> infos = new ArrayList<DlogInfo>();
+
+ DlogInfo info = null;
+
+ for (String line : lines) {
+ // ignore empty line.
+ if (line.length() <= 0) {
+ continue;
+ }
+
+ // check if the line is header line.
+ String[] matches = StringUtil.split(line, pattern);
+
+ // a header line
+ if (matches!=null && matches.length == 3) {
+ info = new DlogInfo();
+ info.setLogLevel(LogLevel.getByName(matches[0]));
+ info.setTag(matches[1]);
+ info.setCommand(matches[2]);
+
+ infos.add(info);
+ }
+ }
+
+ return infos.toArray(new DlogInfo[0]);
+ }
+}
diff --git a/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogParserFactory.java b/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogParserFactory.java
index 6db3eadbc..d2625ee11 100644
--- a/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogParserFactory.java
+++ b/org.tizen.common.sdblib/src/org/tizen/sdblib/dlog/DlogParserFactory.java
@@ -43,6 +43,8 @@ public class DlogParserFactory {
parser = new DlogBriefParser();
} else if (format.equals(DlogFormat.LONG)) {
parser = new DlogLongParser();
+ } else if (format.equals(DlogFormat.JOURNAL)) {
+ parser = new DlogJournalParser();
} else {
//could not support yet.
}
diff --git a/org.tizen.common/src/org/tizen/common/TizenPlatformConstants.java b/org.tizen.common/src/org/tizen/common/TizenPlatformConstants.java
index d56b6fcf4..0c5c7efb2 100644
--- a/org.tizen.common/src/org/tizen/common/TizenPlatformConstants.java
+++ b/org.tizen.common/src/org/tizen/common/TizenPlatformConstants.java
@@ -96,6 +96,7 @@ public class TizenPlatformConstants {
public static final String PKG_TOOL_ROAPP_CHECK_COMMAND;
public static final String REMOVE_FILE_COMMAND;
public static final String DLOGUTIL_CMD;
+ public static final String JOURNAL_CMD;
public static final String ROAPP_RESULT;
public static final String RWAPP_RESULT;
@@ -184,6 +185,8 @@ public class TizenPlatformConstants {
// Should be absolute path
DLOGUTIL_CMD = "/usr/bin/dlogutil %s";
+ JOURNAL_CMD = "/usr/bin/journalctl %s";
+
DEBUG_ATTACH_CMD_FORMAT = "-m debug -P %s -attach %s";
}