Skip to content
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

Functions_368 Fixing indentation and spacing in app logs cli #4303

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,56 +55,60 @@ const Logs: FunctionComponent<LogsProps> = ({pollOptions: {jwtToken, filters}, r
<Text color={prefix.status === 'Success' ? 'green' : 'red'}>{prefix.status}</Text>
<Text>{prefix.description}</Text>
</Box>
{appLog instanceof FunctionRunLog && (
<>
<Text>{appLog.logs}</Text>
{appLog.input && (
<>
<Text>Input ({appLog.inputBytes} bytes):</Text>
<Text>{prettyPrintJsonIfPossible(appLog.input)}</Text>
</>
)}
{appLog.output && (
<>
<Text>Output ({appLog.outputBytes} bytes):</Text>
<Text>{prettyPrintJsonIfPossible(appLog.output)}</Text>
</>
)}
</>
)}
{appLog instanceof NetworkAccessResponseFromCacheLog && (
<>
<Text>Cache write time: {new Date(appLog.cacheEntryEpochMs).toISOString()}</Text>
<Text>Cache TTL: {appLog.cacheTtlMs / 1000} s</Text>
<Text>HTTP request:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpRequest)}</Text>
<Text>HTTP response:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpResponse)}</Text>
</>
)}
{appLog instanceof NetworkAccessRequestExecutionInBackgroundLog && (
<>
<Text>Reason: {getBackgroundExecutionReasonMessage(appLog.reason)}</Text>
<Text>HTTP request:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpRequest)}</Text>
</>
)}
{appLog instanceof NetworkAccessRequestExecutedLog && (
<>
<Text>Attempt: {appLog.attempt}</Text>
{appLog.connectTimeMs && <Text>Connect time: {appLog.connectTimeMs} ms</Text>}
{appLog.writeReadTimeMs && <Text>Write read time: {appLog.writeReadTimeMs} ms</Text>}
<Text>HTTP request:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpRequest)}</Text>
{appLog.httpResponse && (
<>
<Text>HTTP response:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpResponse)}</Text>
</>
)}
{appLog.error && <Text>Error: {appLog.error}</Text>}
</>
)}
<Box flexDirection="column" marginLeft={4}>
{appLog instanceof FunctionRunLog && (
<>
<Text>{appLog.logs}</Text>
{appLog.input && (
<>
<Text>Input ({appLog.inputBytes} bytes): </Text>
<Text>{prettyPrintJsonIfPossible(appLog.input)}</Text>
</>
)}
{appLog.output && (
<>
<Text>
{'\n'}Output ({appLog.outputBytes} bytes):
</Text>
<Text>{prettyPrintJsonIfPossible(appLog.output)}</Text>
</>
)}
</>
)}
{appLog instanceof NetworkAccessResponseFromCacheLog && (
<>
<Text>Cache write time: {new Date(appLog.cacheEntryEpochMs).toISOString()}</Text>
<Text>Cache TTL: {appLog.cacheTtlMs / 1000} s</Text>
<Text>HTTP request:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpRequest)}</Text>
<Text>HTTP response:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpResponse)}</Text>
</>
)}
{appLog instanceof NetworkAccessRequestExecutionInBackgroundLog && (
<>
<Text>Reason: {getBackgroundExecutionReasonMessage(appLog.reason)}</Text>
<Text>HTTP request:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpRequest)}</Text>
</>
)}
{appLog instanceof NetworkAccessRequestExecutedLog && (
<>
<Text>Attempt: {appLog.attempt}</Text>
{appLog.connectTimeMs && <Text>Connect time: {appLog.connectTimeMs} ms</Text>}
{appLog.writeReadTimeMs && <Text>Write read time: {appLog.writeReadTimeMs} ms</Text>}
<Text>HTTP request:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpRequest)}</Text>
{appLog.httpResponse && (
<>
<Text>HTTP response:</Text>
<Text>{prettyPrintJsonIfPossible(appLog.httpResponse)}</Text>
</>
)}
{appLog.error && <Text>Error: {appLog.error}</Text>}
</>
)}
</Box>
</Box>
),
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading