Skip to content

Commit

Permalink
Improve debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
schwabe committed Nov 28, 2023
1 parent 8da735f commit a85b59e
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions main/src/main/java/de/blinkt/openvpn/core/StatusListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Locale;

/**
* Created by arne on 09.11.16.
Expand Down Expand Up @@ -165,23 +166,18 @@ private void logExitNotification(ApplicationExitInfo aei, String s) {
@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));
}

}
Expand Down

0 comments on commit a85b59e

Please sign in to comment.