Skip to content

Commit

Permalink
Make debug logging more verbose, and update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
zozs committed Aug 28, 2021
1 parent 9cecc62 commit 61bcbe4
Show file tree
Hide file tree
Showing 3 changed files with 334 additions and 178 deletions.
4 changes: 4 additions & 0 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ export async function setupApp (storage, host, port, externalUrl) {
addDebugRoutes(router, myBaseUrl, myPubKey)
}

app.on('error', (err, ctx) => {
debug('server error %s %s', err, ctx)
})

app.use(router.routes())

return app
Expand Down
14 changes: 14 additions & 0 deletions lib/distributed-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ async function setupHyperspaceServer () {
})
await server.ready()

server.on('client-open', () => {
console.log('A HyperspaceClient has connected')
})
server.on('client-close', () => {
console.log('A HyperspaceClient has disconnected')
})

clients.set('hyperspace-server', server)
}

Expand Down Expand Up @@ -123,6 +130,13 @@ async function setupHyperbeeClient (feedOrPubKey, shouldReplicate) {
throw new Error(`invalid feed or pubkey given, got: ${feedOrPubKey}`)
}

core.on('peer-add', (peer) => {
debug('Started replicating feed %s with new peer: %s/%s', feedOrPubKey, peer.remoteAddress, peer.type)
})
core.on('peer-remove', (peer) => {
debug('Stopped replicating feed %s with peer: %s/%s', feedOrPubKey, peer.remoteAddress, peer.type)
})

const bee = new Hyperbee(core, {
keyEncoding: 'utf-8',
valueEncoding: 'json'
Expand Down
Loading

0 comments on commit 61bcbe4

Please sign in to comment.