mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2024-11-28 02:05:40 -05:00
Don't stringify every packet if debug not enabled (#797)
This commit is contained in:
parent
c7a021d689
commit
7492025d65
1 changed files with 4 additions and 2 deletions
|
@ -83,8 +83,10 @@ class Client extends EventEmitter {
|
|||
parsed.data = parsed.data.params
|
||||
parsed.metadata.state = state
|
||||
debug('read packet ' + state + '.' + parsed.metadata.name)
|
||||
if (debug.enabled) {
|
||||
const s = JSON.stringify(parsed.data, null, 2)
|
||||
debug(s && s.length > 10000 ? parsed.data : s)
|
||||
}
|
||||
this.emit('packet', parsed.data, parsed.metadata, parsed.buffer)
|
||||
this.emit(parsed.metadata.name, parsed.data, parsed.metadata)
|
||||
this.emit('raw.' + parsed.metadata.name, parsed.buffer, parsed.metadata)
|
||||
|
|
Loading…
Reference in a new issue