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

Remove console.logs #402

Merged
merged 1 commit into from
Dec 16, 2016
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
13 changes: 7 additions & 6 deletions client/next-prefetcher.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* global self */

const CACHE_NAME = 'next-prefetcher-v1'
const log = () => {}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, logging is pretty useful when debugging.
So, we keep a log function like this and we can change it to console.log.bind(console) when we need to do some logging.


self.addEventListener('install', () => {
console.log('Installing Next Prefetcher')
log('Installing Next Prefetcher')
})

self.addEventListener('activate', (e) => {
console.log('Activated Next Prefetcher')
log('Activated Next Prefetcher')
e.waitUntil(Promise.all([
resetCache(),
notifyClients()
Expand All @@ -21,12 +22,12 @@ self.addEventListener('fetch', (e) => {
self.addEventListener('message', (e) => {
switch (e.data.action) {
case 'ADD_URL': {
console.log('CACHING ', e.data.url)
log('CACHING ', e.data.url)
sendReply(e, cacheUrl(e.data.url))
break
}
case 'RESET': {
console.log('RESET')
log('RESET')
sendReply(e, resetCache())
break
}
Expand Down Expand Up @@ -65,10 +66,10 @@ function getResponse (req) {
.then((cache) => cache.match(req))
.then((res) => {
if (res) {
console.log('CACHE HIT: ' + req.url)
log('CACHE HIT: ' + req.url)
return res
} else {
console.log('CACHE MISS: ' + req.url)
log('CACHE MISS: ' + req.url)
return self.fetch(req)
}
})
Expand Down
1 change: 0 additions & 1 deletion lib/prefetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ class Messenger {
this.serviceWorkerState = 'REGISTERED'
this.serviceWorkerReadyCallbacks.forEach(cb => cb())
this.serviceWorkerReadyCallbacks = []
console.log('Next Prefetcher registered')
})
}
}
Expand Down