Commit e976bd09 authored by Michał Woźniak's avatar Michał Woźniak
Browse files

WIP #71: implemented self.log() in service-worker.js

parent 8b54e04a
......@@ -65,10 +65,39 @@ if (typeof self.SamizdatConfig !== 'object' || self.SamizdatConfig === null) {
'cache':{},
'alt-fetch':{},
'gun-ipfs':{}
}
},
// which components should be logged?
// this is an array of strings, components not listed here
// will have their debug output disabled
//
// by default, the service worker and all enabled plugins
// (so, all components that are used)
loggedComponents: [
'service-worker',
'fetch',
'cache',
'alt-fetch',
'gun-ipfs'
]
}
}
/**
* internal logging facility
*
* component - name of the component being logged about
* if the component is not in the SamizdatConfig.loggedComponents array,
* message will not be displayed
* items - the rest of arguments will be passed to console.debug()
*/
self.log = function(component, ...items) {
if (component in SamizdatConfig.loggedComponents) {
console.debug(`Samizdat [COMMIT_UNKNOWN, ${component}] ::`, ...items)
}
}
// load the plugins
//
// everything in a try-catch block
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment