diff --git a/android/app/src/main/java/com/mattermost/helpers/CustomPushNotificationHelper.java b/android/app/src/main/java/com/mattermost/helpers/CustomPushNotificationHelper.java index cbdb968b022..bca394932b0 100644 --- a/android/app/src/main/java/com/mattermost/helpers/CustomPushNotificationHelper.java +++ b/android/app/src/main/java/com/mattermost/helpers/CustomPushNotificationHelper.java @@ -20,7 +20,6 @@ import android.os.Bundle; import android.text.TextUtils; import android.util.Base64; -import android.util.Log; import androidx.annotation.NonNull; import androidx.core.app.NotificationCompat; @@ -32,6 +31,7 @@ import com.mattermost.rnbeta.*; import com.mattermost.rnutils.helpers.NotificationHelper; import com.nozbe.watermelondb.WMDatabase; +import com.mattermost.turbolog.TurboLog; import java.io.IOException; import java.security.KeyFactory; @@ -241,36 +241,36 @@ public static void createNotificationChannels(Context context) { public static boolean verifySignature(final Context context, String signature, String serverUrl, String ackId) { if (signature == null) { // Backward compatibility with old push proxies - Log.i("Mattermost Notifications Signature verification", "No signature in the notification"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "No signature in the notification"); return true; } if (serverUrl == null) { - Log.i("Mattermost Notifications Signature verification", "No server_url for server_id"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "No server_url for server_id"); return false; } DatabaseHelper dbHelper = DatabaseHelper.Companion.getInstance(); if (dbHelper == null) { - Log.i("Mattermost Notifications Signature verification", "Cannot access the database"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "Cannot access the database"); return false; } WMDatabase db = getDatabaseForServer(dbHelper, context, serverUrl); if (db == null) { - Log.i("Mattermost Notifications Signature verification", "Cannot access the server database"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "Cannot access the server database"); return false; } if (signature.equals("NO_SIGNATURE")) { String version = queryConfigServerVersion(db); if (version == null) { - Log.i("Mattermost Notifications Signature verification", "No server version"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "No server version"); return false; } if (!version.matches("[0-9]+(\\.[0-9]+)*")) { - Log.i("Mattermost Notifications Signature verification", "Invalid server version"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "Invalid server version"); return false; } @@ -324,7 +324,7 @@ public static boolean verifySignature(final Context context, String signature, S } if (rejected) { - Log.i("Mattermost Notifications Signature verification", "Server version should send signature"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "Server version should send signature"); return false; } @@ -334,7 +334,7 @@ public static boolean verifySignature(final Context context, String signature, S String signingKey = queryConfigSigningKey(db); if (signingKey == null) { - Log.i("Mattermost Notifications Signature verification", "No signing key"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "No signing key"); return false; } @@ -345,17 +345,17 @@ public static boolean verifySignature(final Context context, String signature, S String storedDeviceToken = getDeviceToken(dbHelper); if (storedDeviceToken == null) { - Log.i("Mattermost Notifications Signature verification", "No device token stored"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "No device token stored"); return false; } String[] tokenParts = storedDeviceToken.split(":", 2); if (tokenParts.length != 2) { - Log.i("Mattermost Notifications Signature verification", "Wrong stored device token format"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "Wrong stored device token format"); return false; } String deviceToken = tokenParts[1].substring(0, tokenParts[1].length() -1 ); if (deviceToken.isEmpty()) { - Log.i("Mattermost Notifications Signature verification", "Empty stored device token"); + TurboLog.Companion.i("Mattermost Notifications Signature verification", "Empty stored device token"); return false; } @@ -366,19 +366,19 @@ public static boolean verifySignature(final Context context, String signature, S .build() .parseSignedClaims(signature); } catch (MissingClaimException e) { - Log.i("Mattermost Notifications Signature verification", String.format("Missing claim: %s", e.getMessage())); + TurboLog.Companion.i("Mattermost Notifications Signature verification", String.format("Missing claim: %s", e.getMessage())); e.printStackTrace(); return false; } catch (IncorrectClaimException e) { - Log.i("Mattermost Notifications Signature verification", String.format("Incorrect claim: %s", e.getMessage())); + TurboLog.Companion.i("Mattermost Notifications Signature verification", String.format("Incorrect claim: %s", e.getMessage())); e.printStackTrace(); return false; } catch (JwtException e) { - Log.i("Mattermost Notifications Signature verification", String.format("Cannot verify JWT: %s", e.getMessage())); + TurboLog.Companion.i("Mattermost Notifications Signature verification", String.format("Cannot verify JWT: %s", e.getMessage())); e.printStackTrace(); return false; } catch (Exception e) { - Log.i("Mattermost Notifications Signature verification", String.format("Exception while parsing JWT: %s", e.getMessage())); + TurboLog.Companion.i("Mattermost Notifications Signature verification", String.format("Exception while parsing JWT: %s", e.getMessage())); e.printStackTrace(); return false; } @@ -572,7 +572,7 @@ private static Bitmap userAvatar(final Context context, @NonNull final String se Double lastUpdateAt = 0.0; if (!TextUtils.isEmpty(urlOverride)) { Request request = new Request.Builder().url(urlOverride).build(); - Log.i("ReactNative", String.format("Fetch override profile image %s", urlOverride)); + TurboLog.Companion.i("ReactNative", String.format("Fetch override profile image %s", urlOverride)); response = client.newCall(request).execute(); } else { DatabaseHelper dbHelper = DatabaseHelper.Companion.getInstance(); @@ -594,7 +594,7 @@ private static Bitmap userAvatar(final Context context, @NonNull final String se bitmapCache.removeBitmap(userId, serverUrl); String url = String.format("api/v4/users/%s/image", userId); - Log.i("ReactNative", String.format("Fetch profile image %s", url)); + TurboLog.Companion.i("ReactNative", String.format("Fetch profile image %s", url)); response = Network.getSync(serverUrl, url, null); } diff --git a/android/app/src/main/java/com/mattermost/helpers/PushNotificationDataHelper.kt b/android/app/src/main/java/com/mattermost/helpers/PushNotificationDataHelper.kt index 08a3a3e1c98..437e13072d6 100644 --- a/android/app/src/main/java/com/mattermost/helpers/PushNotificationDataHelper.kt +++ b/android/app/src/main/java/com/mattermost/helpers/PushNotificationDataHelper.kt @@ -2,7 +2,6 @@ package com.mattermost.helpers import android.content.Context import android.os.Bundle -import android.util.Log import com.facebook.react.bridge.Arguments import com.facebook.react.bridge.ReadableArray import com.facebook.react.bridge.ReadableMap @@ -15,6 +14,7 @@ import com.mattermost.helpers.push_notification.fetchNeededUsers import com.mattermost.helpers.push_notification.fetchPosts import com.mattermost.helpers.push_notification.fetchTeamIfNeeded import com.mattermost.helpers.push_notification.fetchThread +import com.mattermost.turbolog.TurboLog import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock @@ -50,7 +50,7 @@ class PushNotificationDataRunnable { val isCRTEnabled = initialData.getString("is_crt_enabled") == "true" val ackId = initialData.getString("ack_id") - Log.i("ReactNative", "Start fetching notification data in server=$serverUrl for channel=$channelId and ack=$ackId") + TurboLog.i("ReactNative", "Start fetching notification data in server=$serverUrl for channel=$channelId and ack=$ackId") val receivingThreads = isCRTEnabled && !rootId.isNullOrEmpty() val notificationData = Arguments.createMap() @@ -104,13 +104,13 @@ class PushNotificationDataRunnable { dbHelper.saveToDatabase(db, notificationData, teamId, channelId, receivingThreads) } - Log.i("ReactNative", "Done processing push notification=$serverUrl for channel=$channelId and ack=$ackId") + TurboLog.i("ReactNative", "Done processing push notification=$serverUrl for channel=$channelId and ack=$ackId") } } catch (e: Exception) { e.printStackTrace() } finally { db?.close() - Log.i("ReactNative", "DONE fetching notification data") + TurboLog.i("ReactNative", "DONE fetching notification data") } return result diff --git a/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.kt b/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.kt index 2c3e1f5db0d..4bd0cf4c1c7 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.kt +++ b/android/app/src/main/java/com/mattermost/rnbeta/CustomPushNotification.kt @@ -3,7 +3,6 @@ package com.mattermost.rnbeta import android.app.PendingIntent import android.content.Context import android.os.Bundle -import android.util.Log import androidx.core.app.NotificationCompat import com.mattermost.helpers.CustomPushNotificationHelper import com.mattermost.helpers.DatabaseHelper @@ -11,6 +10,7 @@ import com.mattermost.helpers.Network import com.mattermost.helpers.PushNotificationDataHelper import com.mattermost.helpers.database_extension.getServerUrlForIdentifier import com.mattermost.rnutils.helpers.NotificationHelper +import com.mattermost.turbolog.TurboLog import com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_EVENT_NAME import com.wix.reactnativenotifications.core.AppLaunchHelper import com.wix.reactnativenotifications.core.AppLifecycleFacade @@ -84,7 +84,7 @@ class CustomPushNotification( } if (!CustomPushNotificationHelper.verifySignature(mContext, signature, serverUrl, ackId)) { - Log.i("Mattermost Notifications Signature verification", "Notification skipped because we could not verify it.") + TurboLog.i("Mattermost Notifications Signature verification", "Notification skipped because we could not verify it.") return } @@ -104,7 +104,7 @@ class CustomPushNotification( when (type) { CustomPushNotificationHelper.PUSH_TYPE_MESSAGE, CustomPushNotificationHelper.PUSH_TYPE_SESSION -> { val currentActivityName = mAppLifecycleFacade.runningReactContext?.currentActivity?.componentName?.className ?: "" - Log.i("ReactNative", currentActivityName) + TurboLog.i("ReactNative", currentActivityName) if (!mAppLifecycleFacade.isAppVisible() || currentActivityName != "MainActivity") { var createSummary = type == CustomPushNotificationHelper.PUSH_TYPE_MESSAGE if (type == CustomPushNotificationHelper.PUSH_TYPE_MESSAGE) { diff --git a/android/app/src/main/java/com/mattermost/rnbeta/MainApplication.kt b/android/app/src/main/java/com/mattermost/rnbeta/MainApplication.kt index fb323ac4807..bc9fbc82bc4 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/MainApplication.kt +++ b/android/app/src/main/java/com/mattermost/rnbeta/MainApplication.kt @@ -5,7 +5,6 @@ import android.annotation.SuppressLint import android.content.Context import android.content.res.Configuration import android.os.Bundle -import android.util.Log import com.facebook.react.PackageList import com.facebook.react.ReactHost import com.facebook.react.ReactInstanceManager @@ -20,6 +19,8 @@ import com.facebook.react.modules.network.OkHttpClientProvider import com.facebook.soloader.SoLoader import com.mattermost.networkclient.RCTOkHttpClientFactory import com.mattermost.rnshare.helpers.RealPathUtil +import com.mattermost.turbolog.TurboLog +import com.mattermost.turbolog.ConfigureOptions import com.nozbe.watermelondb.jsi.JSIInstaller import com.reactnativenavigation.NavigationApplication import com.wix.reactnativenotifications.RNNotificationsPackage @@ -63,7 +64,9 @@ class MainApplication : NavigationApplication(), INotificationsApplication { // Delete any previous temp files created by the app val tempFolder = File(applicationContext.cacheDir, RealPathUtil.CACHE_DIR_NAME) RealPathUtil.deleteTempFiles(tempFolder) - Log.i("ReactNative", "Cleaning temp cache " + tempFolder.absolutePath) + TurboLog.configure(options = ConfigureOptions(logsDirectory = applicationContext.cacheDir.absolutePath + "/logs", logPrefix = applicationContext.packageName)) + + TurboLog.i("ReactNative", "Cleaning temp cache " + tempFolder.absolutePath) // Tells React Native to use our RCTOkHttpClientFactory which builds an OKHttpClient // with a cookie jar defined in APIClientModule and an interceptor to intercept all diff --git a/android/app/src/main/java/com/mattermost/rnbeta/NotificationDismissService.java b/android/app/src/main/java/com/mattermost/rnbeta/NotificationDismissService.java index 6f72fb5ffc8..e66deb6ae03 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/NotificationDismissService.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/NotificationDismissService.java @@ -4,9 +4,9 @@ import android.content.Intent; import android.app.IntentService; import android.os.Bundle; -import android.util.Log; import com.mattermost.rnutils.helpers.NotificationHelper; +import com.mattermost.turbolog.TurboLog; import com.wix.reactnativenotifications.core.NotificationIntentAdapter; public class NotificationDismissService extends IntentService { @@ -20,6 +20,6 @@ protected void onHandleIntent(Intent intent) { final Bundle bundle = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent); NotificationHelper.INSTANCE.dismissNotification(context, bundle); - Log.i("ReactNative", "Dismiss notification"); + TurboLog.Companion.i("ReactNative", "Dismiss notification"); } } diff --git a/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java b/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java index d606b767114..e6afd609ec3 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/NotificationReplyBroadcastReceiver.java @@ -8,7 +8,6 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.util.Log; import androidx.annotation.Nullable; import androidx.core.app.NotificationCompat; @@ -18,6 +17,7 @@ import com.facebook.react.bridge.WritableMap; import com.mattermost.helpers.*; +import com.mattermost.turbolog.TurboLog; import com.wix.reactnativenotifications.core.NotificationIntentAdapter; import com.wix.reactnativenotifications.core.notification.PushNotificationProps; @@ -82,22 +82,22 @@ protected void replyToMessage(final String serverUrl, final int notificationId, public void resolve(@Nullable Object value) { if (value != null) { onReplySuccess(notificationId, message); - Log.i("ReactNative", "Reply SUCCESS"); + TurboLog.Companion.i("ReactNative", "Reply SUCCESS"); } else { - Log.i("ReactNative", "Reply FAILED resolved without value"); + TurboLog.Companion.i("ReactNative", "Reply FAILED resolved without value"); onReplyFailed(notificationId); } } @Override public void reject(Throwable reason) { - Log.i("ReactNative", String.format("Reply FAILED exception %s", reason.getMessage())); + TurboLog.Companion.i("ReactNative", String.format("Reply FAILED exception %s", reason.getMessage())); onReplyFailed(notificationId); } @Override public void reject(String code, String message) { - Log.i("ReactNative", + TurboLog.Companion.i("ReactNative", String.format("Reply FAILED status %s BODY %s", code, message) ); onReplyFailed(notificationId); diff --git a/android/app/src/main/java/com/mattermost/rnbeta/ReceiptDelivery.java b/android/app/src/main/java/com/mattermost/rnbeta/ReceiptDelivery.java index 9b3c8f0db28..09a5e20f2c1 100644 --- a/android/app/src/main/java/com/mattermost/rnbeta/ReceiptDelivery.java +++ b/android/app/src/main/java/com/mattermost/rnbeta/ReceiptDelivery.java @@ -1,7 +1,6 @@ package com.mattermost.rnbeta; import android.os.Bundle; -import android.util.Log; import java.lang.System; import java.util.Objects; @@ -12,6 +11,7 @@ import com.facebook.react.bridge.WritableMap; import com.mattermost.helpers.*; +import com.mattermost.turbolog.TurboLog; import okhttp3.Response; @@ -19,7 +19,7 @@ public class ReceiptDelivery { private static final String[] ackKeys = new String[]{"post_id", "root_id", "category", "message", "team_id", "channel_id", "channel_name", "type", "sender_id", "sender_name", "version"}; public static Bundle send(final String ackId, final String serverUrl, final String postId, final String type, final boolean isIdLoaded) { - Log.i("ReactNative", String.format("Send receipt delivery ACK=%s TYPE=%s to URL=%s with ID-LOADED=%s", ackId, type, serverUrl, isIdLoaded)); + TurboLog.Companion.i("ReactNative", String.format("Send receipt delivery ACK=%s TYPE=%s to URL=%s with ID-LOADED=%s", ackId, type, serverUrl, isIdLoaded)); WritableMap options = Arguments.createMap(); WritableMap headers = Arguments.createMap(); WritableMap body = Arguments.createMap(); diff --git a/package-lock.json b/package-lock.json index 5727f1b6762..3db8b9e0836 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "@mattermost/react-native-emm": "1.5.0", "@mattermost/react-native-network-client": "1.7.3", "@mattermost/react-native-paste-input": "0.8.0", - "@mattermost/react-native-turbo-log": "0.4.0", + "@mattermost/react-native-turbo-log": "github:mattermost/react-native-turbo-log#d8ddf5e7974546aff3e83b2c563907eb609ac5f4", "@mattermost/rnshare": "file:./libraries/@mattermost/rnshare", "@mattermost/rnutils": "file:./libraries/@mattermost/rnutils", "@msgpack/msgpack": "2.8.0", @@ -5947,8 +5947,9 @@ }, "node_modules/@mattermost/react-native-turbo-log": { "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@mattermost/react-native-turbo-log/-/react-native-turbo-log-0.4.0.tgz", - "integrity": "sha512-9W0t/FUTyA4mw+RJJ17TXuaPnz/FyBUSDn8poxkdrVjdpeWcIVQCbPOba3BcwDh3owx2JFbp+zGa5PmCHz6Veg==", + "resolved": "git+ssh://git@github.com/mattermost/react-native-turbo-log.git#d8ddf5e7974546aff3e83b2c563907eb609ac5f4", + "integrity": "sha512-ccUGRO2osFTp18ilnKagJa3wHBiaPQtGw2A5Z5+zBsLJTtbdkSQjanjgojgsllhLYj4NCi/VrVXTxks/eLusmw==", + "license": "MIT", "peerDependencies": { "react": "*", "react-native": "*" diff --git a/package.json b/package.json index fb9cb76bc08..cdfb35fbd84 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@mattermost/react-native-emm": "1.5.0", "@mattermost/react-native-network-client": "1.7.3", "@mattermost/react-native-paste-input": "0.8.0", - "@mattermost/react-native-turbo-log": "0.4.0", + "@mattermost/react-native-turbo-log": "github:mattermost/react-native-turbo-log#d8ddf5e7974546aff3e83b2c563907eb609ac5f4", "@mattermost/rnshare": "file:./libraries/@mattermost/rnshare", "@mattermost/rnutils": "file:./libraries/@mattermost/rnutils", "@msgpack/msgpack": "2.8.0",