Skip to content

Commit

Permalink
Fixing broken remote logs fetching: reverting back toJson method in
Browse files Browse the repository at this point in the history
LogEntry (and dependency on json lib is back too)
  • Loading branch information
barancev committed Feb 27, 2013
1 parent 930ad8d commit 3a511f1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
12 changes: 12 additions & 0 deletions java/client/src/org/openqa/selenium/logging/LogEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;

import org.json.JSONObject;

/**
* Represents a single log statement.
*/
Expand Down Expand Up @@ -91,5 +95,13 @@ private SimpleDateFormat getDateFormat() {

return format;
}

public JSONObject toJson() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("timestamp", timestamp);
map.put("level", level);
map.put("message", message);
return new JSONObject(map);
}

}
1 change: 1 addition & 0 deletions java/client/src/org/openqa/selenium/logging/build.desc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ java_library(
],
deps = [
"//java/client/src/org/openqa/selenium:beta",
"//third_party/java/json",
])

java_library(
Expand Down
2 changes: 0 additions & 2 deletions java/client/src/org/openqa/selenium/remote/RemoteLogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,12 @@ public LogEntries get(String logType) {
}

private LogEntries getRemoteEntries(String logType) {
System.out.println("Getting log " + logType);
Object raw = executeMethod.execute(DriverCommand.GET_LOG, ImmutableMap.of(TYPE_KEY, logType));
@SuppressWarnings("unchecked")
List<Map<String, Object>> rawList = (List<Map<String, Object>>) raw;
List<LogEntry> remoteEntries = Lists.newArrayListWithCapacity(rawList.size());

for (Map<String, Object> obj : rawList) {
System.out.println(obj);
remoteEntries.add(new LogEntry(LogLevelMapping.toLevel((String)obj.get(LEVEL)),
(Long) obj.get(TIMESTAMP),
(String) obj.get(MESSAGE)));
Expand Down

0 comments on commit 3a511f1

Please sign in to comment.