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:35 UTC
[openmeetings] branch master updated: [OPENMEETINGS-1142] logging
is improved
This is an automated email from the ASF dual-hosted git repository.
solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git
The following commit(s) were added to refs/heads/master by this push:
new 3459c40 [OPENMEETINGS-1142] logging is improved
3459c40 is described below
commit 3459c408fc33a00c227a339f518682178a762fe9
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 2c1a65f..bfd2918 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;
@@ -38,7 +39,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;
@@ -130,17 +130,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 581d312..cc23021 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 java.io.File;
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 fbce288..a52f23e 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 java.io.File;
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 864bdc6..a6eba61 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;
@@ -81,14 +82,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);
}
}
@@ -110,6 +111,7 @@ public class ProcessHelper {
Process proc = null;
StreamWatcher errorWatcher = null;
StreamWatcher inputWatcher = null;
+ final long start = System.currentTimeMillis();
try {
res.setCommand(getCommand(argv)).setOut("");
@@ -136,7 +138,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) {