Skip to content

Commit

Permalink
Merge pull request #498 from ephemeraHQ/noe/native-logs
Browse files Browse the repository at this point in the history
Implement the native logs method in debug menu
  • Loading branch information
nmalzieu authored Aug 12, 2024
2 parents 670c30d + 7ee4927 commit cfce17f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
12 changes: 12 additions & 0 deletions components/DebugButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
rotateLoggingFile,
} from "@utils/logger";
import { navigate } from "@utils/navigation";
import { getNativeLogFile } from "@utils/xmtpRN/logs";
import axios from "axios";
import Constants from "expo-constants";
import { Image } from "expo-image";
Expand Down Expand Up @@ -48,6 +49,13 @@ const DebugButton = forwardRef((props, ref) => {
url: `file://${loggingFilePath}`,
});
},
"Share native logs": async () => {
const nativeLogFilePath = await getNativeLogFile();
Share.share({
title: "LibXMTP Logs",
url: `file://${nativeLogFilePath}`,
});
},
"Share previous session logs": async () => {
const previousLoggingFile = await getPreviousSessionLoggingFile();
if (!previousLoggingFile) {
Expand All @@ -62,6 +70,10 @@ const DebugButton = forwardRef((props, ref) => {
"Display current session logs": async () => {
navigate("WebviewPreview", { uri: loggingFilePath });
},
"Display native logs": async () => {
const nativeLogFilePath = await getNativeLogFile();
navigate("WebviewPreview", { uri: nativeLogFilePath });
},
"Display previous session logs": async () => {
const previousLoggingFile = await getPreviousSessionLoggingFile();
if (!previousLoggingFile) {
Expand Down
2 changes: 1 addition & 1 deletion ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ install! 'cocoapods',


# Version must match version from XMTP Podspec (matching @xmtp/react-native-sdk from package.json)
# https://github.com/xmtp/xmtp-react-native/blob/v2.2.5/ios/XMTPReactNative.podspec#L29
# https://github.com/xmtp/xmtp-react-native/blob/v2.4.1/ios/XMTPReactNative.podspec#L29
$xmtpVersion = '0.14.1'

# Pinning MMKV to 1.3.3 that has included that fix https://github.com/Tencent/MMKV/pull/1222#issuecomment-1905164314
Expand Down
14 changes: 7 additions & 7 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,7 @@ SPEC CHECKSUMS:
GenericJSON: 79a840eeb77030962e8cf02a62d36bd413b67626
glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f
GzipSwift: 893f3e48e597a1a4f62fafcb6514220fcf8287fa
hermes-engine: 767c3b922b9b0bc2d781aeee462f8b55bf285218
hermes-engine: 8c1577f3fdb849cbe7729c2e7b5abc4b845e88f8
libavif: 84bbb62fb232c3018d6f1bab79beea87e35de7b7
libdav1d: 23581a4d8ec811ff171ed5e2e05cd27bad64c39f
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
Expand All @@ -2269,7 +2269,7 @@ SPEC CHECKSUMS:
op-sqlite: 1ca30186b8d062cd451f1d999c691caf151d13e2
OpenSSL-Universal: 6e1ae0555546e604dbc632a2b9a24a9c46c41ef6
RCT-Folly: 02617c592a293bd6d418e0a88ff4ee1f88329b47
RCTDeprecation: 121d32efb5b3b0712c2c177beb858d050e5f48c5
RCTDeprecation: 3afceddffa65aee666dafd6f0116f1d975db1584
RCTRequired: ec1239bc9d8bf63e10fb92bd8b26171a9258e0c1
RCTTypeSafety: f5ecbc86c5c5fa163c05acb7a1c5012e15b5f994
ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979
Expand Down Expand Up @@ -2334,7 +2334,7 @@ SPEC CHECKSUMS:
rn-fetch-blob: f065bb7ab7fb48dd002629f8bdcb0336602d3cba
RNAWSCognito: fe0c870c7cd9970a2efefc075b3f2d75eac913c7
RNCAsyncStorage: 826b603ae9c0f88b5ac4e956801f755109fa4d5c
RNCClipboard: 327eda72df65abf65e430eeb2e527cf95264ab12
RNCClipboard: 0a720adef5ec193aa0e3de24c3977222c7e52a37
RNDeviceInfo: 02ea8b23e2280fa18e00a06d7e62804d74028579
RNFlashList: b521ebdd7f9352673817f1d98e8bdc0c8cf8545b
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
Expand All @@ -2343,8 +2343,8 @@ SPEC CHECKSUMS:
RNReactNativeSharedGroupPreferences: de0121a4224c267bc7e9fb16c398f3f087c8da81
RNReanimated: d51431fd3597a8f8320319dce8e42cee82a5445f
RNScreens: 30249f9331c3b00ae7cb7922e11f58b3ed369c07
RNSentry: 906151a5ec2887a48af16d11ad635249d7a5a59b
RNSVG: 16a7fd5293e14799a541332ece19c22d1509ed3b
RNSentry: e9aa15bb2f3e18c822c002eea13bbd3b222ab493
RNSVG: 43b64ed39c14ce830d840903774154ca0c1f27ec
SDWebImage: 066c47b573f408f18caa467d71deace7c0f8280d
SDWebImageAVIFCoder: 00310d246aab3232ce77f1d8f0076f8c4b021d90
SDWebImageSVGCoder: 15a300a97ec1c8ac958f009c02220ac0402e936c
Expand All @@ -2361,6 +2361,6 @@ SPEC CHECKSUMS:
XMTPReactNative: 352bc2ff9f26133cad5f73a147224e72f7e1450c
Yoga: 1ab23c1835475da69cf14e211a560e73aab24cb0

PODFILE CHECKSUM: 170760880c444127b891465e24c4450a402d9091
PODFILE CHECKSUM: 9855135dc3989f63855c6e54bf63e1c363d4b894

COCOAPODS: 1.12.1
COCOAPODS: 1.15.2
13 changes: 13 additions & 0 deletions utils/xmtpRN/logs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Client } from "@xmtp/react-native-sdk";
import path from "path";
import * as RNFS from "react-native-fs";

export const getNativeLogFile = async () => {
const nativeLogs = (await Client.exportNativeLogs()) as string;
const nativeLogFilePath = path.join(
RNFS.TemporaryDirectoryPath,
"libxmtp.logs.txt"
);
await RNFS.writeFile(nativeLogFilePath, nativeLogs, "utf8");
return nativeLogFilePath;
};
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9583,7 +9583,7 @@

"@xmtp/react-native-sdk@^2.4.1":
version "2.4.1"
resolved "https://registry.npmjs.org/@xmtp/react-native-sdk/-/react-native-sdk-2.4.1.tgz#862884a1dba377ef867526ccd9e9a1d1dc98154a"
resolved "https://registry.yarnpkg.com/@xmtp/react-native-sdk/-/react-native-sdk-2.4.1.tgz#862884a1dba377ef867526ccd9e9a1d1dc98154a"
integrity sha512-yVnHsAUb58ex/ypADWqwGnPYi1Xsk98UUUNpFCd/8+/kym1mEghSz8subBt3/ZjYOx49ie0wggRsVlY7jDq85g==
dependencies:
"@ethersproject/bytes" "^5.7.0"
Expand Down

0 comments on commit cfce17f

Please sign in to comment.