Download logs section
This commit is contained in:
parent
b64ea43d20
commit
fd0018c1bc
|
@ -0,0 +1,17 @@
|
|||
<script>
|
||||
import { Layout, Body, Button } from "@budibase/bbui"
|
||||
import { downloadStream } from "@budibase/frontend-core"
|
||||
|
||||
import { API } from "api"
|
||||
|
||||
async function download() {
|
||||
downloadStream(await API.getServerLogs())
|
||||
}
|
||||
</script>
|
||||
|
||||
<Layout noPadding>
|
||||
<Body>Download your latest logs to share with the Budibase team</Body>
|
||||
<div class="download-button">
|
||||
<Button cta on:click={download}>Download system logs</Button>
|
||||
</div>
|
||||
</Layout>
|
|
@ -85,6 +85,13 @@ export const menu = derived([admin, auth], ([$admin, $auth]) => {
|
|||
title: "Audit Logs",
|
||||
href: "/builder/portal/account/auditLogs",
|
||||
})
|
||||
|
||||
if (!$admin.cloud) {
|
||||
accountSubPages.push({
|
||||
title: "System Logs",
|
||||
href: "/builder/portal/account/systemLogs",
|
||||
})
|
||||
}
|
||||
}
|
||||
if ($admin.cloud && $auth?.user?.accountPortalAccess) {
|
||||
accountSubPages.push({
|
||||
|
|
|
@ -12,8 +12,17 @@ export function downloadText(filename, text) {
|
|||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
export async function downloadStream(filename, streamResponse) {
|
||||
export async function downloadStream(streamResponse) {
|
||||
const blob = await streamResponse.blob()
|
||||
|
||||
const contentDisposition = streamResponse.headers.get("Content-Disposition")
|
||||
|
||||
const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(
|
||||
contentDisposition
|
||||
)
|
||||
|
||||
const filename = matches[1].replace(/['"]/g, "")
|
||||
|
||||
const resBlob = new Blob([blob])
|
||||
|
||||
const blobUrl = URL.createObjectURL(resBlob)
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import { UserCtx } from "@budibase/types"
|
||||
import { logging } from "@budibase/backend-core"
|
||||
import { context, logging } from "@budibase/backend-core"
|
||||
|
||||
export async function getLogs(ctx: UserCtx) {
|
||||
const logReadStream = logging.system.getLogReadStream()
|
||||
|
||||
const fileName = `${context.getTenantId()}-${Date.now()}.logs`
|
||||
|
||||
ctx.set("content-disposition", `attachment; filename=${fileName}`)
|
||||
ctx.body = logReadStream
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue