fix: set up logger from Svelte app on app boot

This commit is contained in:
Ondřej Synáček 2020-12-20 15:06:08 +01:00
parent 29ad7fcf73
commit 377a4bcd80
3 changed files with 10 additions and 15 deletions

View File

@ -3,12 +3,14 @@ import App from './components/App.svelte'
import * as stores from './stores'
import * as services from './services'
import serviceWorkerBoot from './sw-boot'
import loggerBoot from './logger-boot'
const boot = () => {
services.storageListener.register()
serviceWorkerBoot()
loggerBoot()
new App({
target: document.querySelector('#root'),

View File

@ -0,0 +1,8 @@
import logger from '../static/app/logger'
import { configStore } from './stores'
export default () => {
const enableTracking = configStore.track
logger.setRemoteLogging(enableTracking)
}

View File

@ -14,19 +14,4 @@ import { Request } from '../frontend/records'
(() => {
document.addEventListener('DOMContentLoaded', boot)
const configureLogger = (logger) => {
if (!logger) {
return
}
const prevStorage = getConfigStorage()
const storageContents = getStorageContents(prevStorage)
const shouldTrack = Boolean(storageContents.track)
logger.setRemoteLogging(shouldTrack)
}
configureLogger(logger)
})()