You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2018/08/02 12:09:16 UTC

[openmeetings] branch 4.0.x updated: [OPENMEETINGS-1142] logging is improved

This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch 4.0.x
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/4.0.x by this push:
     new 2ac6bf5  [OPENMEETINGS-1142] logging is improved
2ac6bf5 is described below

commit 2ac6bf51feb45672b230318b235eb7c35eb29cd5
Author: Maxim Solodovnik <so...@gmail.com>
AuthorDate: Thu Aug 2 19:09:07 2018 +0700

    [OPENMEETINGS-1142] logging is improved
---
 .../apache/openmeetings/core/converter/BaseConverter.java   | 13 +------------
 .../openmeetings/core/converter/InterviewConverter.java     |  1 +
 .../openmeetings/core/converter/RecordingConverter.java     |  1 +
 .../java/org/apache/openmeetings/util/CalendarHelper.java   | 12 ++++++++++++
 .../org/apache/openmeetings/util/process/ProcessHelper.java |  8 +++++---
 5 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/BaseConverter.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/BaseConverter.java
index 4d4465a..af7039b 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/BaseConverter.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/BaseConverter.java
@@ -21,6 +21,7 @@ package org.apache.openmeetings.core.converter;
 import static org.apache.commons.io.FileUtils.copyFile;
 import static org.apache.commons.lang3.math.NumberUtils.toInt;
 import static org.apache.openmeetings.core.data.record.listener.async.BaseStreamWriter.TIME_TO_WAIT_FOR_FRAME;
+import static org.apache.openmeetings.util.CalendarHelper.formatMillis;
 import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_FLV;
 import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_PNG;
 import static org.apache.openmeetings.util.OmFileHelper.getRecordingMetaData;
@@ -39,7 +40,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -132,17 +132,6 @@ public abstract class BaseConverter {
 		return ((double)val) / 1000;
 	}
 
-	protected String formatMillis(long millis) {
-		long m = millis;
-		long hours = TimeUnit.MILLISECONDS.toHours(m);
-		m -= TimeUnit.HOURS.toMillis(hours);
-		long minutes = TimeUnit.MILLISECONDS.toMinutes(m);
-		m -= TimeUnit.MINUTES.toMillis(minutes);
-		long seconds = TimeUnit.MILLISECONDS.toSeconds(m);
-		m -= TimeUnit.SECONDS.toMillis(seconds);
-		return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, m);
-	}
-
 	protected void updateDuration(Recording r) {
 		r.setDuration(formatMillis(diff(r.getRecordEnd(), r.getRecordStart())));
 	}
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/InterviewConverter.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/InterviewConverter.java
index 42b377e..95150f7 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/InterviewConverter.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/InterviewConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.openmeetings.core.converter;
 
+import static org.apache.openmeetings.util.CalendarHelper.formatMillis;
 import static org.apache.openmeetings.util.OmFileHelper.getRecordingMetaData;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
 
diff --git a/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/RecordingConverter.java b/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/RecordingConverter.java
index 40c37df..29b7862 100644
--- a/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/RecordingConverter.java
+++ b/openmeetings-core/src/main/java/org/apache/openmeetings/core/converter/RecordingConverter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.openmeetings.core.converter;
 
+import static org.apache.openmeetings.util.CalendarHelper.formatMillis;
 import static org.apache.openmeetings.util.OmFileHelper.EXTENSION_FLV;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebAppRootKey;
 
diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarHelper.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarHelper.java
index 7828fc8..b880245 100644
--- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarHelper.java
+++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/CalendarHelper.java
@@ -24,6 +24,7 @@ import java.time.LocalDateTime;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
 import java.util.Date;
+import java.util.concurrent.TimeUnit;
 
 public class CalendarHelper {
 	public static ZoneId getZoneId(String tzId) {
@@ -50,4 +51,15 @@ public class CalendarHelper {
 	public static LocalDateTime getDateTime(Date d, String tzId) {
 		return getZoneDateTime(d == null ? new Date() : d, tzId).toLocalDateTime();
 	}
+
+	public static String formatMillis(long millis) {
+		long m = millis;
+		long hours = TimeUnit.MILLISECONDS.toHours(m);
+		m -= TimeUnit.HOURS.toMillis(hours);
+		long minutes = TimeUnit.MILLISECONDS.toMinutes(m);
+		m -= TimeUnit.MINUTES.toMillis(minutes);
+		long seconds = TimeUnit.MILLISECONDS.toSeconds(m);
+		m -= TimeUnit.SECONDS.toMillis(seconds);
+		return String.format("%02d:%02d:%02d.%03d", hours, minutes, seconds, m);
+	}
 }
diff --git a/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java b/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java
index cd3a3fb..96b6c52 100644
--- a/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java
+++ b/openmeetings-util/src/main/java/org/apache/openmeetings/util/process/ProcessHelper.java
@@ -19,6 +19,7 @@
 package org.apache.openmeetings.util.process;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.openmeetings.util.CalendarHelper.formatMillis;
 import static org.apache.openmeetings.util.OpenmeetingsVariables.getExtProcessTtl;
 
 import java.io.BufferedReader;
@@ -82,14 +83,14 @@ public class ProcessHelper {
 
 	private static void debugCommandStart(String desc, String[] argv) {
 		if (log.isDebugEnabled()) {
-			log.debug("START " + desc + " ################# ");
+			log.debug("START {} ################# ", desc);
 			log.debug(getCommand(argv));
 		}
 	}
 
 	private static void debugCommandEnd(String desc) {
 		if (log.isDebugEnabled()) {
-			log.debug("END " + desc + " ################# ");
+			log.debug("END {} ################# ", desc);
 		}
 	}
 
@@ -111,6 +112,7 @@ public class ProcessHelper {
 		Process proc = null;
 		StreamWatcher errorWatcher = null;
 		StreamWatcher inputWatcher = null;
+		final long start = System.currentTimeMillis();
 		try {
 			res.setCommand(getCommand(argv)).setOut("");
 
@@ -137,7 +139,7 @@ public class ProcessHelper {
 		} catch (Throwable t) {
 			log.error("executeScript", t);
 			res.setExitCode(-1)
-				.setError(t.getMessage())
+				.setError(String.format("Exception after %s of work; %s", formatMillis(System.currentTimeMillis() - start), t.getMessage()))
 				.setException(t.toString());
 		} finally {
 			if (proc != null) {