Conversation
| @@ -0,0 +1,79 @@ | |||
| // @ts-ignore | |||
There was a problem hiding this comment.
This is kind of dumb but I had to do it because we can't use anything that uses the fs package in ios or android. We have to split it up amongst the desktop/node environments and mobile.
| @@ -0,0 +1,17 @@ | |||
| --- node_modules/react-native-file-logger/android/src/main/AndroidManifest.xml 2025-03-11 23:02:55 | |||
There was a problem hiding this comment.
These two patches implement functionality that it's in review on react-native-file-logger but haven't been released yet.
| const char *logs = "/logs"; | ||
| jstring logs_js = env->NewStringUTF(logs); | ||
| jclass cls_StringBuilder = env->FindClass("java/lang/StringBuilder"); | ||
| jmethodID ctr_StringBuilder = env->GetMethodID(cls_StringBuilder, "<init>", "(I)V"); | ||
| jobject stringBuilder = env->NewObject(cls_StringBuilder, ctr_StringBuilder, 100); | ||
| jmethodID mid_StringBuilder_append = env->GetMethodID(cls_StringBuilder, "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;"); | ||
| for (auto str: { dataPath, logs_js }) { | ||
| env->CallObjectMethod(stringBuilder, mid_StringBuilder_append, str); | ||
| } | ||
| jmethodID mid_StringBuilder_toString = env->GetMethodID(cls_StringBuilder, "toString", "()Ljava/lang/String;"); | ||
| auto js_log_path = (jstring) env->CallObjectMethod(stringBuilder, mid_StringBuilder_toString); | ||
| const char* log_path = env->GetStringUTFChars(js_log_path, nullptr); |
There was a problem hiding this comment.
I mentioned before I'm not great with C++, this is what came up when I searched how to concatenate two jstring variables. I have to imagine there's a simpler way but this works.
|
|
||
| // @ts-ignore | ||
| nodeConsoleLogger[printLevel](...formattedLogStrings) | ||
| this.internalLogMethod(level, formattedLogStrings.join(' ')) |
There was a problem hiding this comment.
This allows us to easily swap in different log mechanisms depending on the envrionment.
| import { createQuietLogger, DEFAULT_INTERNAL_LOG_METHOD, __nodeConsoleLogger } from '@quiet/logger' | ||
|
|
||
| export const createLogger = createQuietLogger('identity') | ||
| export const createLogger = (() => { |
There was a problem hiding this comment.
Everywhere that I'm doing this funky try/catch is meant to avoid the fs import errors on mobile. The only place we load this package is in desktop environments and the backend so any of these common packages won't break in a react native environment.
| let splash: BrowserWindow | null | ||
| let invitationUrl: string | null | ||
|
|
||
| if (isDev || process.env.DATA_DIR) { |
There was a problem hiding this comment.
This logic just got moved to loadMainEnvs so we could ensure the log env variables are set as early as possible.
* Publish - @quiet/desktop@4.0.3-alpha.0 - @quiet/mobile@4.0.3-alpha.0 * Update packages CHANGELOG.md * Update CHANGELOG.md * chore(2771): Logging to files (#2772) * Log to files alongside console via winston * Add flag for skipping to log to file * Update index.ts * Update CHANGELOG.md * Add support for mobile * Fix dependency issues * Fix CI bootstrap * Test fixes * Fix mocks * Remove debug logs * Publish - @quiet/desktop@4.0.3-alpha.1 - @quiet/mobile@4.0.3-alpha.1 * Update packages CHANGELOG.md * Fix falsy check * Another bad boolean check * Publish - @quiet/desktop@4.0.3-alpha.2 - @quiet/mobile@4.0.3-alpha.2 * Update packages CHANGELOG.md * fix(2770): Avoid continuous redials, better queued redials, libp2p uses QuietLogger (#2773) * Use QuietLogger in libp2p and better redials/reconnects * Update snapshots * Bump up some timeouts for tests and tweak redial settings * More tweaks * Update snapshots * Publish - @quiet/desktop@4.0.3-alpha.3 - @quiet/mobile@4.0.3-alpha.3 * Update packages CHANGELOG.md * Update READMEs and comments * Update package.json * Update package version and fix parallel logs
Pull Request Checklist
(Optional) Mobile checklist
Please ensure you completed the following checks if you did any changes to the mobile package: