diff --git a/packages/app/src/cli/services/app-logs/logs-command/ui/components/Logs.test.tsx b/packages/app/src/cli/services/app-logs/logs-command/ui/components/Logs.test.tsx index 22bfcc5727..a446ccbf70 100644 --- a/packages/app/src/cli/services/app-logs/logs-command/ui/components/Logs.test.tsx +++ b/packages/app/src/cli/services/app-logs/logs-command/ui/components/Logs.test.tsx @@ -63,7 +63,7 @@ const USE_POLL_APP_LOGS_RETURN_VALUE = { prefix: { functionId: FUNCTION_ID, logTimestamp: TIME, - description: `export "run" executed in 0.5124 M instructions`, + description: `export "run" executed in 0.5124M instructions`, status: STATUS === 'success' ? 'Success' : 'Failure', source: SOURCE, }, @@ -171,96 +171,97 @@ describe('Logs', () => { const lastFrame = renderInstance.lastFrame() expect(unstyled(lastFrame!)).toMatchInlineSnapshot(` - "2024-06-18 16:02:04.868 my-function Success export \\"run\\" executed in 0.5124 M instructions - test logs - Input (10 bytes): - { - \\"test\\": \\"input\\" - } - Output (10 bytes): - { - \\"test\\": \\"output\\" - } + "2024-06-18 16:02:04.868 my-function Success export \\"run\\" executed in 0.5124M instructions + test logs + Input (10 bytes): + { + \\"test\\": \\"input\\" + } + + Output (10 bytes): + { + \\"test\\": \\"output\\" + } 2024-06-18 16:02:04.868 my-function Success network access response from cache - Cache write time: 2023-05-12T15:17:01.000Z - Cache TTL: 300 s - HTTP request: - { - \\"url\\": \\"https://api.example.com/hello\\", - \\"method\\": \\"GET\\", - \\"headers\\": {}, - \\"body\\": null, - \\"policy\\": { - \\"read_timeout_ms\\": 500 - } - } - HTTP response: - { - \\"status\\": 200, - \\"body\\": \\"Success\\", - \\"headers\\": { - \\"header1\\": \\"value1\\" - } - } + Cache write time: 2023-05-12T15:17:01.000Z + Cache TTL: 300 s + HTTP request: + { + \\"url\\": \\"https://api.example.com/hello\\", + \\"method\\": \\"GET\\", + \\"headers\\": {}, + \\"body\\": null, + \\"policy\\": { + \\"read_timeout_ms\\": 500 + } + } + HTTP response: + { + \\"status\\": 200, + \\"body\\": \\"Success\\", + \\"headers\\": { + \\"header1\\": \\"value1\\" + } + } 2024-06-18 16:02:04.868 my-function Success network access request executed in 80 ms - Attempt: 1 - Connect time: 40 ms - Write read time: 40 ms - HTTP request: - { - \\"url\\": \\"https://api.example.com/hello\\", - \\"method\\": \\"GET\\", - \\"headers\\": {}, - \\"body\\": null, - \\"policy\\": { - \\"read_timeout_ms\\": 500 - } - } - HTTP response: - { - \\"status\\": 200, - \\"body\\": \\"Success\\", - \\"headers\\": { - \\"header1\\": \\"value1\\" - } - } + Attempt: 1 + Connect time: 40 ms + Write read time: 40 ms + HTTP request: + { + \\"url\\": \\"https://api.example.com/hello\\", + \\"method\\": \\"GET\\", + \\"headers\\": {}, + \\"body\\": null, + \\"policy\\": { + \\"read_timeout_ms\\": 500 + } + } + HTTP response: + { + \\"status\\": 200, + \\"body\\": \\"Success\\", + \\"headers\\": { + \\"header1\\": \\"value1\\" + } + } 2024-06-18 16:02:04.868 my-function Failure network access request executed - Attempt: 1 - HTTP request: - { - \\"url\\": \\"https://api.example.com/hello\\", - \\"method\\": \\"GET\\", - \\"headers\\": {}, - \\"body\\": null, - \\"policy\\": { - \\"read_timeout_ms\\": 500 - } - } - Error: Timeout Error + Attempt: 1 + HTTP request: + { + \\"url\\": \\"https://api.example.com/hello\\", + \\"method\\": \\"GET\\", + \\"headers\\": {}, + \\"body\\": null, + \\"policy\\": { + \\"read_timeout_ms\\": 500 + } + } + Error: Timeout Error 2024-06-18 16:02:04.868 my-function Success network access request executing in background - Reason: No cached response available - HTTP request: - { - \\"url\\": \\"https://api.example.com/hello\\", - \\"method\\": \\"GET\\", - \\"headers\\": {}, - \\"body\\": null, - \\"policy\\": { - \\"read_timeout_ms\\": 500 - } - } + Reason: No cached response available + HTTP request: + { + \\"url\\": \\"https://api.example.com/hello\\", + \\"method\\": \\"GET\\", + \\"headers\\": {}, + \\"body\\": null, + \\"policy\\": { + \\"read_timeout_ms\\": 500 + } + } 2024-06-18 16:02:04.868 my-function Success network access request executing in background - Reason: Cache is about to expire - HTTP request: - { - \\"url\\": \\"https://api.example.com/hello\\", - \\"method\\": \\"GET\\", - \\"headers\\": {}, - \\"body\\": null, - \\"policy\\": { - \\"read_timeout_ms\\": 500 - } - }" + Reason: Cache is about to expire + HTTP request: + { + \\"url\\": \\"https://api.example.com/hello\\", + \\"method\\": \\"GET\\", + \\"headers\\": {}, + \\"body\\": null, + \\"policy\\": { + \\"read_timeout_ms\\": 500 + } + }" `) renderInstance.unmount() diff --git a/packages/app/src/cli/services/app-logs/logs-command/ui/components/Logs.tsx b/packages/app/src/cli/services/app-logs/logs-command/ui/components/Logs.tsx index a6d922b40a..f5d909d7b6 100644 --- a/packages/app/src/cli/services/app-logs/logs-command/ui/components/Logs.tsx +++ b/packages/app/src/cli/services/app-logs/logs-command/ui/components/Logs.tsx @@ -55,56 +55,60 @@ const Logs: FunctionComponent = ({pollOptions: {jwtToken, filters}, r {prefix.status} {prefix.description} - {appLog instanceof FunctionRunLog && ( - <> - {appLog.logs} - {appLog.input && ( - <> - Input ({appLog.inputBytes} bytes): - {prettyPrintJsonIfPossible(appLog.input)} - - )} - {appLog.output && ( - <> - Output ({appLog.outputBytes} bytes): - {prettyPrintJsonIfPossible(appLog.output)} - - )} - - )} - {appLog instanceof NetworkAccessResponseFromCacheLog && ( - <> - Cache write time: {new Date(appLog.cacheEntryEpochMs).toISOString()} - Cache TTL: {appLog.cacheTtlMs / 1000} s - HTTP request: - {prettyPrintJsonIfPossible(appLog.httpRequest)} - HTTP response: - {prettyPrintJsonIfPossible(appLog.httpResponse)} - - )} - {appLog instanceof NetworkAccessRequestExecutionInBackgroundLog && ( - <> - Reason: {getBackgroundExecutionReasonMessage(appLog.reason)} - HTTP request: - {prettyPrintJsonIfPossible(appLog.httpRequest)} - - )} - {appLog instanceof NetworkAccessRequestExecutedLog && ( - <> - Attempt: {appLog.attempt} - {appLog.connectTimeMs && Connect time: {appLog.connectTimeMs} ms} - {appLog.writeReadTimeMs && Write read time: {appLog.writeReadTimeMs} ms} - HTTP request: - {prettyPrintJsonIfPossible(appLog.httpRequest)} - {appLog.httpResponse && ( - <> - HTTP response: - {prettyPrintJsonIfPossible(appLog.httpResponse)} - - )} - {appLog.error && Error: {appLog.error}} - - )} + + {appLog instanceof FunctionRunLog && ( + <> + {appLog.logs} + {appLog.input && ( + <> + Input ({appLog.inputBytes} bytes): + {prettyPrintJsonIfPossible(appLog.input)} + + )} + {appLog.output && ( + <> + + {'\n'}Output ({appLog.outputBytes} bytes): + + {prettyPrintJsonIfPossible(appLog.output)} + + )} + + )} + {appLog instanceof NetworkAccessResponseFromCacheLog && ( + <> + Cache write time: {new Date(appLog.cacheEntryEpochMs).toISOString()} + Cache TTL: {appLog.cacheTtlMs / 1000} s + HTTP request: + {prettyPrintJsonIfPossible(appLog.httpRequest)} + HTTP response: + {prettyPrintJsonIfPossible(appLog.httpResponse)} + + )} + {appLog instanceof NetworkAccessRequestExecutionInBackgroundLog && ( + <> + Reason: {getBackgroundExecutionReasonMessage(appLog.reason)} + HTTP request: + {prettyPrintJsonIfPossible(appLog.httpRequest)} + + )} + {appLog instanceof NetworkAccessRequestExecutedLog && ( + <> + Attempt: {appLog.attempt} + {appLog.connectTimeMs && Connect time: {appLog.connectTimeMs} ms} + {appLog.writeReadTimeMs && Write read time: {appLog.writeReadTimeMs} ms} + HTTP request: + {prettyPrintJsonIfPossible(appLog.httpRequest)} + {appLog.httpResponse && ( + <> + HTTP response: + {prettyPrintJsonIfPossible(appLog.httpResponse)} + + )} + {appLog.error && Error: {appLog.error}} + + )} + ), )} diff --git a/packages/app/src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.test.tsx b/packages/app/src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.test.tsx index 1568c7bf8c..3dfa0f5f42 100644 --- a/packages/app/src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.test.tsx +++ b/packages/app/src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.test.tsx @@ -211,7 +211,7 @@ describe('usePollAppLogs', () => { expect(hook.lastResult?.appLogOutputs[0]!.prefix).toEqual({ status: 'Success', source: SOURCE, - description: `export "run" executed in ${(FUEL_CONSUMED / 1000000).toFixed(4)} M instructions`, + description: `export "run" executed in ${(FUEL_CONSUMED / 1000000).toFixed(4)}M instructions`, logTimestamp: TIME, }) diff --git a/packages/app/src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.ts b/packages/app/src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.ts index 3e96aa8a0f..76f74bd276 100644 --- a/packages/app/src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.ts +++ b/packages/app/src/cli/services/app-logs/logs-command/ui/components/hooks/usePollAppLogs.ts @@ -68,7 +68,7 @@ export function usePollAppLogs({initialJwt, filters, resubscribeCallback}: UsePo appLog = parseFunctionRunPayload(log.payload) description = `export "${appLog.export}" executed in ${(appLog.fuelConsumed / ONE_MILLION).toFixed( 4, - )} M instructions` + )}M instructions` break case LOG_TYPE_RESPONSE_FROM_CACHE: appLog = parseNetworkAccessResponseFromCachePayload(log.payload)