Skip to content

Commit d1ec3b9

Browse files
committed
Allow the debug setting to be set from the program using the library.
1 parent e9a102e commit d1ec3b9

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

postgres.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ process.mixin(require('./postgres-js/md5'));
66
var tcp = require("tcp");
77
var sys = require("sys");
88

9-
var DEBUG = 0;
9+
exports.DEBUG = 0;
1010

1111
String.prototype.add_header = function (code) {
1212
if (code === undefined) {
@@ -206,9 +206,9 @@ exports.Connection = function (database, username, password, port) {
206206
// Sends a message to the postgres server
207207
function sendMessage(type, args) {
208208
var stream = formatter[type].apply(this, args);
209-
if (DEBUG > 0) {
209+
if (exports.DEBUG > 0) {
210210
sys.debug("Sending " + type + ": " + JSON.stringify(args));
211-
if (DEBUG > 2) {
211+
if (exports.DEBUG > 2) {
212212
sys.debug("->" + JSON.stringify(stream));
213213
}
214214
}
@@ -230,7 +230,7 @@ exports.Connection = function (database, username, password, port) {
230230
}
231231
}
232232

233-
if (DEBUG > 2) {
233+
if (exports.DEBUG > 2) {
234234
sys.debug("<-" + JSON.stringify(data));
235235
}
236236

@@ -239,12 +239,12 @@ exports.Connection = function (database, username, password, port) {
239239
var len = data.substr(1, 4).parse_int32()[1];
240240
var stream = data.substr(5, len - 4);
241241
data = data.substr(len + 1);
242-
if (DEBUG > 1) {
242+
if (exports.DEBUG > 1) {
243243
sys.debug("stream: " + code + " " + JSON.stringify(stream));
244244
}
245245
var command = parse_response(code, stream);
246246
if (command.type) {
247-
if (DEBUG > 0) {
247+
if (exports.DEBUG > 0) {
248248
sys.debug("Received " + command.type + ": " + JSON.stringify(command.args));
249249
}
250250
command.args.unshift(command.type);

0 commit comments

Comments
 (0)