mirror of
https://github.com/PrismarineJS/node-minecraft-protocol.git
synced 2025-07-05 09:20:20 -04:00
reorganize code a bit : debug code going to debug.js, put packets reading code in a function, add types using a addTypes function
This commit is contained in:
parent
fe443e84ff
commit
78e70dad8e
4 changed files with 102 additions and 95 deletions
src
17
src/debug.js
Normal file
17
src/debug.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
var util = require('util')
|
||||
|
||||
var debug;
|
||||
if (process.env.NODE_DEBUG && /(minecraft-protocol|mc-proto)/.test(process.env.NODE_DEBUG)) {
|
||||
var pid = process.pid;
|
||||
debug = function(x) {
|
||||
// if console is not set up yet, then skip this.
|
||||
if (!console.error)
|
||||
return;
|
||||
console.error('MC-PROTO: %d', pid,
|
||||
util.format.apply(util, arguments).slice(0, 500));
|
||||
};
|
||||
} else {
|
||||
debug = function() { };
|
||||
}
|
||||
|
||||
module.exports = debug;
|
Loading…
Add table
Add a link
Reference in a new issue