enh: watch instance logging

This commit is contained in:
Ben Allfree 2023-06-19 05:13:37 -07:00
parent c5173e0380
commit c0bfc643a4

View File

@ -256,7 +256,7 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
update: (log: InstanceLogFields) => void, update: (log: InstanceLogFields) => void,
nInitial = 100 nInitial = 100
): (() => void) => { ): (() => void) => {
const { dbg } = _logger.create('watchInstanceLog') const { dbg, trace } = _logger.create('watchInstanceLog')
const auth = client.authStore.exportToCookie() const auth = client.authStore.exportToCookie()
const controller = new AbortController() const controller = new AbortController()
@ -274,10 +274,10 @@ export const createPocketbaseClient = (config: PocketbaseClientConfig) => {
auth auth
}), }),
onmessage: (event) => { onmessage: (event) => {
dbg(`Got stream event`, event) trace(`Got stream event`, event)
const {} = event const {} = event
const log = JSON.parse(event.data) as InstanceLogFields const log = JSON.parse(event.data) as InstanceLogFields
dbg(`Log is`, log) trace(`Log is`, log)
update(log) update(log)
}, },
onopen: async (response) => { onopen: async (response) => {