Repository navigation
fix(mobile): keep ordinary offline outbox failures out of console.warn #13144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e286d19
fix(mobile): keep ordinary offline outbox failures out of console.warn
juliusmarminge 62eed73
fix(mobile): warn on nontransport settings-sync outbox failures
juliusmarminge 34b6394
fix(mobile): keep rpc decode defects warning and tag upload logs
juliusmarminge df3bae3
docs(mobile): scope the rpc defect classifier comment to the request …
juliusmarminge c110833
chore(mobile): drop the dedicated logging tests
juliusmarminge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,14 @@ | ||
| import { createDebugLogger } from "../../lib/debugLog"; | ||
|
|
||
| const logger = createDebugLogger("cloud", { | ||
| enabledInDev: true, | ||
| legacyGlobalFlag: "__T3_CLOUD_DEBUG__", | ||
| }); | ||
|
|
||
| export function isCloudDebugEnabled(): boolean { | ||
| return ( | ||
| (typeof __DEV__ !== "undefined" && __DEV__) || | ||
| (typeof globalThis !== "undefined" && | ||
| (globalThis as { __T3_CLOUD_DEBUG__?: boolean }).__T3_CLOUD_DEBUG__ === true) | ||
| ); | ||
| return logger.isEnabled(); | ||
| } | ||
|
|
||
| export function cloudDebugLog(event: string, data?: Record<string, unknown>): void { | ||
| if (!isCloudDebugEnabled()) { | ||
| return; | ||
| } | ||
| if (data) { | ||
| console.log(`[t3-cloud] ${event}`, data); | ||
| } else { | ||
| console.log(`[t3-cloud] ${event}`); | ||
| } | ||
| logger.log(event, data); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,21 @@ | ||
| import { createDebugLogger } from "../../lib/debugLog"; | ||
|
|
||
| /** | ||
| * Debug logging for the mobile terminal pipeline. Prefix: `[t3-terminal]`. | ||
| * | ||
| * Enabled when `__DEV__` is true, or set `globalThis.__T3_TERMINAL_DEBUG__ = true` in a JS | ||
| * debugger / Metro console to trace release/TestFlight builds. | ||
| * Enabled when `__DEV__` is true, or set `globalThis.__T3_TERMINAL_DEBUG__` | ||
| * (or the shared `globalThis.__T3_DEBUG__` filter) in a JS debugger / Metro | ||
| * console to trace release/TestFlight builds. | ||
| */ | ||
| const logger = createDebugLogger("terminal", { | ||
| enabledInDev: true, | ||
| legacyGlobalFlag: "__T3_TERMINAL_DEBUG__", | ||
| }); | ||
|
|
||
| export function isTerminalDebugEnabled(): boolean { | ||
| return ( | ||
| (typeof __DEV__ !== "undefined" && __DEV__) || | ||
| (typeof globalThis !== "undefined" && | ||
| (globalThis as { __T3_TERMINAL_DEBUG__?: boolean }).__T3_TERMINAL_DEBUG__ === true) | ||
| ); | ||
| return logger.isEnabled(); | ||
| } | ||
|
|
||
| export function terminalDebugLog(message: string, data?: Record<string, unknown>): void { | ||
| if (!isTerminalDebugEnabled()) { | ||
| return; | ||
| } | ||
| if (data !== undefined) { | ||
| console.log(`[t3-terminal] ${message}`, data); | ||
| } else { | ||
| console.log(`[t3-terminal] ${message}`); | ||
| } | ||
| logger.log(message, data); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /** | ||
| * Namespaced, filterable debug logging shared by mobile subsystems. | ||
| * | ||
| * Ordinary, expected conditions — a queued send failing while the device is | ||
| * offline, for example — go through a debug logger instead of `console.warn` | ||
| * so warning output stays reserved for failures someone can act on. Output | ||
| * uses `console.log` with a `[t3-<namespace>]` prefix, matching the existing | ||
| * cloud and terminal debug logs. (client-runtime cannot host this: its | ||
| * tooling bans `console.*` in favor of Effect logging.) | ||
| * | ||
| * A logger is silent in every build, including development, unless enabled. | ||
| * Toggle it from a JS debugger or the Metro console, including on release/TestFlight builds: | ||
| * - `globalThis.__T3_DEBUG__ = true` enables every namespace; | ||
| * - `globalThis.__T3_DEBUG__ = ["thread-outbox"]` enables only listed ones. | ||
| * | ||
| * Subsystems whose traces are useful by default in development (`__DEV__`) | ||
| * opt in with `enabledInDev`; `legacyGlobalFlag` keeps an older | ||
| * subsystem-specific global (e.g. `__T3_CLOUD_DEBUG__`) working. | ||
| */ | ||
|
|
||
| export interface DebugLogger { | ||
| readonly isEnabled: () => boolean; | ||
| readonly log: (event: string, data?: Record<string, unknown>) => void; | ||
| } | ||
|
|
||
| export interface DebugLoggerOptions { | ||
| /** Log whenever `__DEV__` is true, without the global filter. Defaults to false. */ | ||
| readonly enabledInDev?: boolean; | ||
| /** Name of a legacy subsystem-specific global boolean, e.g. `"__T3_CLOUD_DEBUG__"`. */ | ||
| readonly legacyGlobalFlag?: string; | ||
| } | ||
|
|
||
| function globalValue(name: string): unknown { | ||
| return typeof globalThis === "undefined" | ||
| ? undefined | ||
| : (globalThis as Record<string, unknown>)[name]; | ||
| } | ||
|
|
||
| export function createDebugLogger( | ||
| namespace: string, | ||
| options: DebugLoggerOptions = {}, | ||
| ): DebugLogger { | ||
| const isEnabled = () => { | ||
| if (options.enabledInDev === true && typeof __DEV__ !== "undefined" && __DEV__) { | ||
| return true; | ||
| } | ||
| if (options.legacyGlobalFlag !== undefined && globalValue(options.legacyGlobalFlag) === true) { | ||
| return true; | ||
| } | ||
| const filter = globalValue("__T3_DEBUG__"); | ||
| return filter === true || (Array.isArray(filter) && filter.includes(namespace)); | ||
| }; | ||
| const log = (event: string, data?: Record<string, unknown>) => { | ||
| if (!isEnabled()) { | ||
| return; | ||
| } | ||
| if (data === undefined) { | ||
| console.log(`[t3-${namespace}] ${event}`); | ||
| } else { | ||
| console.log(`[t3-${namespace}] ${event}`, data); | ||
| } | ||
| }; | ||
| return { isEnabled, log }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.