diff options
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"; } |