diff options
author | Arne Schwabe <arne@rfc2549.org> | 2023-11-28 13:36:46 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2023-11-28 13:36:46 +0100 |
commit | a85b59e84b34a87e94c862334c1def5606e44388 (patch) | |
tree | e7b8e44cd0de7c6826eb30276158a91871afe3ce | |
parent | 8da735fe0a854151d3d314567696cf0915265066 (diff) |
Improve debug logging
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/core/StatusListener.java | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/StatusListener.java b/main/src/main/java/de/blinkt/openvpn/core/StatusListener.java index 7eea523a..f7aef095 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/StatusListener.java +++ b/main/src/main/java/de/blinkt/openvpn/core/StatusListener.java @@ -26,6 +26,7 @@ import java.io.DataInputStream; import java.io.File; import java.io.IOException; import java.util.List; +import java.util.Locale; /** * Created by arne on 09.11.16. @@ -165,23 +166,18 @@ public class StatusListener implements VpnStatus.LogListener { @Override public void newLog(LogItem logItem) { String tag = pkgName + "(OpenVPN)"; + long logAge = System.currentTimeMillis() - logItem.getLogtime(); + if (logAge > 5000) + { + tag += String.format(Locale.US, "[%ds ago]", logAge/1000 ); + } + switch (logItem.getLogLevel()) { - case INFO: - Log.i(tag, logItem.getString(mContext)); - break; - case DEBUG: - Log.d(tag, logItem.getString(mContext)); - break; - case ERROR: - Log.e(tag, logItem.getString(mContext)); - break; - case VERBOSE: - Log.v(tag, logItem.getString(mContext)); - break; - case WARNING: - default: - Log.w(tag, logItem.getString(mContext)); - break; + case INFO -> Log.i(tag, logItem.getString(mContext)); + case DEBUG -> Log.d(tag, logItem.getString(mContext)); + case ERROR -> Log.e(tag, logItem.getString(mContext)); + case VERBOSE -> Log.v(tag, logItem.getString(mContext)); + default -> Log.w(tag, logItem.getString(mContext)); } } |