mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 05:55:39 +03:00
Merge pull request #1377 from nextcloud/bugfix/1013/stopLogFlooding
temporarily disable logging to file
This commit is contained in:
commit
8955015159
5 changed files with 47 additions and 77 deletions
|
@ -226,7 +226,6 @@ public class RestModule {
|
||||||
loggingInterceptor.redactHeader("Proxy-Authorization");
|
loggingInterceptor.redactHeader("Proxy-Authorization");
|
||||||
httpClient.addInterceptor(loggingInterceptor);
|
httpClient.addInterceptor(loggingInterceptor);
|
||||||
} else if (context.getResources().getBoolean(R.bool.nc_is_debug)) {
|
} else if (context.getResources().getBoolean(R.bool.nc_is_debug)) {
|
||||||
|
|
||||||
HttpLoggingInterceptor.Logger fileLogger =
|
HttpLoggingInterceptor.Logger fileLogger =
|
||||||
s -> LoggingUtils.INSTANCE.writeLogEntryToFile(context, s);
|
s -> LoggingUtils.INSTANCE.writeLogEntryToFile(context, s);
|
||||||
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(fileLogger);
|
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(fileLogger);
|
||||||
|
|
|
@ -21,56 +21,49 @@
|
||||||
package com.nextcloud.talk.utils
|
package com.nextcloud.talk.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.net.Uri
|
// TODO: improve log handling. https://github.com/nextcloud/talk-android/issues/1376
|
||||||
import android.os.Build
|
// writing logs to a file is temporarily disabled to avoid huge logfiles.
|
||||||
import androidx.core.content.FileProvider
|
|
||||||
import com.nextcloud.talk.BuildConfig
|
|
||||||
import java.io.FileNotFoundException
|
|
||||||
import java.io.IOException
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
|
|
||||||
object LoggingUtils {
|
object LoggingUtils {
|
||||||
fun writeLogEntryToFile(context: Context, logEntry: String) {
|
fun writeLogEntryToFile(context: Context, logEntry: String) {
|
||||||
val dateFormat = SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.ROOT)
|
// val dateFormat = SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.ROOT)
|
||||||
val date = Date()
|
// val date = Date()
|
||||||
val logEntryWithDateTime = dateFormat.format(date) + ": " + logEntry + "\n"
|
// val logEntryWithDateTime = dateFormat.format(date) + ": " + logEntry + "\n"
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
val outputStream = context.openFileOutput(
|
// val outputStream = context.openFileOutput(
|
||||||
"nc_log.txt",
|
// "nc_log.txt",
|
||||||
Context.MODE_PRIVATE or Context.MODE_APPEND
|
// Context.MODE_PRIVATE or Context.MODE_APPEND
|
||||||
)
|
// )
|
||||||
outputStream.write(logEntryWithDateTime.toByteArray())
|
// outputStream.write(logEntryWithDateTime.toByteArray())
|
||||||
outputStream.flush()
|
// outputStream.flush()
|
||||||
outputStream.close()
|
// outputStream.close()
|
||||||
} catch (e: FileNotFoundException) {
|
// } catch (e: FileNotFoundException) {
|
||||||
e.printStackTrace()
|
// e.printStackTrace()
|
||||||
} catch (e: IOException) {
|
// } catch (e: IOException) {
|
||||||
e.printStackTrace()
|
// e.printStackTrace()
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun sendMailWithAttachment(context: Context) {
|
fun sendMailWithAttachment(context: Context) {
|
||||||
val logFile = context.getFileStreamPath("nc_log.txt")
|
// val logFile = context.getFileStreamPath("nc_log.txt")
|
||||||
val emailIntent = Intent(Intent.ACTION_SEND)
|
// val emailIntent = Intent(Intent.ACTION_SEND)
|
||||||
val mailto = "android@nextcloud.com"
|
// val mailto = "android@nextcloud.com"
|
||||||
emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(mailto))
|
// emailIntent.putExtra(Intent.EXTRA_EMAIL, arrayOf(mailto))
|
||||||
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Talk logs")
|
// emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Talk logs")
|
||||||
emailIntent.type = "text/plain"
|
// emailIntent.type = "text/plain"
|
||||||
emailIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
// emailIntent.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
|
||||||
val uri: Uri
|
// val uri: Uri
|
||||||
|
//
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
|
||||||
uri = Uri.fromFile(logFile)
|
// uri = Uri.fromFile(logFile)
|
||||||
} else {
|
// } else {
|
||||||
uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, logFile)
|
// uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, logFile)
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
emailIntent.putExtra(Intent.EXTRA_STREAM, uri)
|
// emailIntent.putExtra(Intent.EXTRA_STREAM, uri)
|
||||||
emailIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
// emailIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
context.startActivity(emailIntent)
|
// context.startActivity(emailIntent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ import com.nextcloud.talk.events.WebSocketCommunicationEvent;
|
||||||
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
import com.nextcloud.talk.models.json.signaling.DataChannelMessage;
|
||||||
import com.nextcloud.talk.models.json.signaling.DataChannelMessageNick;
|
import com.nextcloud.talk.models.json.signaling.DataChannelMessageNick;
|
||||||
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
import com.nextcloud.talk.models.json.signaling.NCIceCandidate;
|
||||||
import com.nextcloud.talk.utils.LoggingUtils;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.webrtc.DataChannel;
|
import org.webrtc.DataChannel;
|
||||||
|
@ -275,8 +274,6 @@ public class MagicPeerConnectionWrapper {
|
||||||
data.get(bytes);
|
data.get(bytes);
|
||||||
String strData = new String(bytes);
|
String strData = new String(bytes);
|
||||||
Log.d(TAG, "Got msg: " + strData + " over " + TAG + " " + sessionId);
|
Log.d(TAG, "Got msg: " + strData + " over " + TAG + " " + sessionId);
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
|
||||||
"Got msg: " + strData + " over " + peerConnection.hashCode() + " " + sessionId);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DataChannelMessage dataChannelMessage = LoganSquare.parse(strData, DataChannelMessage.class);
|
DataChannelMessage dataChannelMessage = LoganSquare.parse(strData, DataChannelMessage.class);
|
||||||
|
@ -350,8 +347,6 @@ public class MagicPeerConnectionWrapper {
|
||||||
@Override
|
@Override
|
||||||
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
|
public void onIceConnectionChange(PeerConnection.IceConnectionState iceConnectionState) {
|
||||||
peerIceConnectionState = iceConnectionState;
|
peerIceConnectionState = iceConnectionState;
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
|
||||||
"iceConnectionChangeTo: " + iceConnectionState.name() + " over " + peerConnection.hashCode() + " " + sessionId);
|
|
||||||
|
|
||||||
Log.d("iceConnectionChangeTo: ", iceConnectionState.name() + " over " + peerConnection.hashCode() + " " + sessionId);
|
Log.d("iceConnectionChangeTo: ", iceConnectionState.name() + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||||
if (iceConnectionState.equals(PeerConnection.IceConnectionState.CONNECTED)) {
|
if (iceConnectionState.equals(PeerConnection.IceConnectionState.CONNECTED)) {
|
||||||
|
@ -441,17 +436,13 @@ public class MagicPeerConnectionWrapper {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateFailure(String s) {
|
public void onCreateFailure(String s) {
|
||||||
Log.d(TAG, s);
|
Log.d(TAG, "SDPObserver createFailure: " + s + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
|
||||||
"SDPObserver createFailure: " + s + " over " + peerConnection.hashCode() + " " + sessionId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSetFailure(String s) {
|
public void onSetFailure(String s) {
|
||||||
Log.d(TAG, s);
|
Log.d(TAG,"SDPObserver setFailure: " + s + " over " + peerConnection.hashCode() + " " + sessionId);
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
|
||||||
"SDPObserver setFailure: " + s + " over " + peerConnection.hashCode() + " " + sessionId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,7 +40,6 @@ import com.nextcloud.talk.models.json.websocket.ErrorOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.EventOverallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.EventOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.HelloResponseOverallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.HelloResponseOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.models.json.websocket.JoinedRoomOverallWebSocketMessage;
|
import com.nextcloud.talk.models.json.websocket.JoinedRoomOverallWebSocketMessage;
|
||||||
import com.nextcloud.talk.utils.LoggingUtils;
|
|
||||||
import com.nextcloud.talk.utils.MagicMap;
|
import com.nextcloud.talk.utils.MagicMap;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
|
|
||||||
|
@ -152,6 +151,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||||
public void restartWebSocket() {
|
public void restartWebSocket() {
|
||||||
reconnecting = true;
|
reconnecting = true;
|
||||||
|
|
||||||
|
// TODO: when improving logging, keep in mind this issue: https://github.com/nextcloud/talk-android/issues/1013
|
||||||
Log.d(TAG, "restartWebSocket: " + connectionUrl);
|
Log.d(TAG, "restartWebSocket: " + connectionUrl);
|
||||||
Request request = new Request.Builder().url(connectionUrl).build();
|
Request request = new Request.Builder().url(connectionUrl).build();
|
||||||
okHttpClient.newWebSocket(request, this);
|
okHttpClient.newWebSocket(request, this);
|
||||||
|
@ -162,8 +162,6 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||||
public void onMessage(WebSocket webSocket, String text) {
|
public void onMessage(WebSocket webSocket, String text) {
|
||||||
if (webSocket == internalWebSocket) {
|
if (webSocket == internalWebSocket) {
|
||||||
Log.d(TAG, "Receiving : " + webSocket.toString() + " " + text);
|
Log.d(TAG, "Receiving : " + webSocket.toString() + " " + text);
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
|
||||||
"WebSocket " + webSocket.hashCode() + " receiving: " + text);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BaseWebSocketMessage baseWebSocketMessage = LoganSquare.parse(text, BaseWebSocketMessage.class);
|
BaseWebSocketMessage baseWebSocketMessage = LoganSquare.parse(text, BaseWebSocketMessage.class);
|
||||||
|
@ -200,8 +198,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||||
Log.e(TAG, "Received error: " + text);
|
Log.e(TAG, "Received error: " + text);
|
||||||
ErrorOverallWebSocketMessage errorOverallWebSocketMessage = LoganSquare.parse(text, ErrorOverallWebSocketMessage.class);
|
ErrorOverallWebSocketMessage errorOverallWebSocketMessage = LoganSquare.parse(text, ErrorOverallWebSocketMessage.class);
|
||||||
if (("no_such_session").equals(errorOverallWebSocketMessage.getErrorWebSocketMessage().getCode())) {
|
if (("no_such_session").equals(errorOverallWebSocketMessage.getErrorWebSocketMessage().getCode())) {
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
Log.d(TAG, "WebSocket " + webSocket.hashCode() + " resumeID " + resumeId + " expired");
|
||||||
"WebSocket " + webSocket.hashCode() + " resumeID " + resumeId + " expired");
|
|
||||||
resumeId = "";
|
resumeId = "";
|
||||||
currentRoomToken = "";
|
currentRoomToken = "";
|
||||||
restartWebSocket();
|
restartWebSocket();
|
||||||
|
@ -299,9 +296,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
Log.e(TAG, "Failed to recognize WebSocket message", e);
|
||||||
"WebSocket " + webSocket.hashCode() + " IOException: " + e.getMessage());
|
|
||||||
Log.e(TAG, "Failed to recognize WebSocket message");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,15 +315,11 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||||
@Override
|
@Override
|
||||||
public void onClosing(WebSocket webSocket, int code, String reason) {
|
public void onClosing(WebSocket webSocket, int code, String reason) {
|
||||||
Log.d(TAG, "Closing : " + code + " / " + reason);
|
Log.d(TAG, "Closing : " + code + " / " + reason);
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
|
||||||
"WebSocket " + webSocket.hashCode() + " Closing: " + reason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||||
Log.d(TAG, "Error : " + t.getMessage());
|
Log.d(TAG, "Error : WebSocket " + webSocket.hashCode() + " onFailure: " + t.getMessage());
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
|
||||||
"WebSocket " + webSocket.hashCode() + " onFailure: " + t.getMessage());
|
|
||||||
closeWebSocket(webSocket);
|
closeWebSocket(webSocket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,9 +357,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||||
internalWebSocket.send(message);
|
internalWebSocket.send(message);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
Log.e(TAG, "Failed to serialize signaling message", e);
|
||||||
"WebSocket sendCalLMessage: " + e.getMessage() + "\n" + ncMessageWrapper.toString());
|
|
||||||
Log.e(TAG, "Failed to serialize signaling message");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,9 +376,7 @@ public class MagicWebSocketInstance extends WebSocketListener {
|
||||||
internalWebSocket.send(message);
|
internalWebSocket.send(message);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LoggingUtils.INSTANCE.writeLogEntryToFile(context,
|
Log.e(TAG, "Failed to offer request. sessionIdParam: " + sessionIdParam + " roomType:" + roomType, e);
|
||||||
"WebSocket requestOfferForSessionIdWithType: " + e.getMessage() + "\n" + sessionIdParam + " " + roomType);
|
|
||||||
Log.e(TAG, "Failed to offer request");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
439
|
438
|
Loading…
Reference in a new issue