From 32512cde904d1c3915ea7c50262275e067a42ff7 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 9 Nov 2009 16:30:47 -0800 Subject: [PATCH 1/3] include the same fields as Event Viewer in EventLogRecord.toString --- .../java/src/org/hyperic/sigar/win32/EventLogRecord.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java b/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java index 2ddaa2f9..bd28ba41 100644 --- a/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java +++ b/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java @@ -179,10 +179,13 @@ public class EventLogRecord { public String toString() { return - "[" + new Date(getTimeGenerated() * 1000) + "] " + "[" + getEventTypeString() + "] " + + "[" + new Date(getTimeGenerated() * 1000) + "] " + "[" + getSource() + "] " + "[" + getCategoryString() + "] " + + "[" + getEventId() + "] " + + "[" + getUser() + "] " + + "[" + getComputerName() + "] " + getMessage(); } } From e86a150a8d7f8b03e58698484d85442b9a4a5a3b Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 9 Nov 2009 16:34:31 -0800 Subject: [PATCH 2/3] 'N/A' for null user in EventLogRecord.toString --- .../src/org/hyperic/sigar/win32/EventLogRecord.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java b/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java index bd28ba41..cc432970 100644 --- a/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java +++ b/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java @@ -25,6 +25,8 @@ import java.util.Date; */ public class EventLogRecord { + private static final String NA = "N/A"; + long recordNumber; long timeGenerated; long timeWritten; @@ -158,7 +160,14 @@ public class EventLogRecord { public String getUser() { return this.user; } - + + private String getUserString() { + if (this.user == null) { + return NA; + } + return this.user; + } + /** * Get the message for the event. */ @@ -184,7 +193,7 @@ public class EventLogRecord { "[" + getSource() + "] " + "[" + getCategoryString() + "] " + "[" + getEventId() + "] " + - "[" + getUser() + "] " + + "[" + getUserString() + "] " + "[" + getComputerName() + "] " + getMessage(); } From 035a097325a604235163141425691b965b1e80a0 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 9 Nov 2009 16:45:06 -0800 Subject: [PATCH 3/3] only display event code in toString as the Event Viewer does --- bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java b/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java index cc432970..3ed7cb7c 100644 --- a/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java +++ b/bindings/java/src/org/hyperic/sigar/win32/EventLogRecord.java @@ -192,7 +192,7 @@ public class EventLogRecord { "[" + new Date(getTimeGenerated() * 1000) + "] " + "[" + getSource() + "] " + "[" + getCategoryString() + "] " + - "[" + getEventId() + "] " + + "[" + (getEventId() & 0xFFFF) + "] " + "[" + getUserString() + "] " + "[" + getComputerName() + "] " + getMessage();