Skip to content

Commit 07bfe07

Browse files
committed
Add redis errors to the log
1 parent 23b66d3 commit 07bfe07

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/store/redis.js

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var log = require("winston");
12
var redis = require("redis");
23

34
var DEFAULT_HOST = "127.0.0.1";
@@ -58,6 +59,12 @@ function firstDefinedIndex (targets) {
5859
return -1;
5960
}
6061

62+
function logErr(err) {
63+
if (err) {
64+
log.error("REDIS error:", err);
65+
}
66+
}
67+
6168
exports.create = function (BaseStore, host, port, db) {
6269
var client = createClient(host, port, db);
6370

@@ -67,6 +74,7 @@ exports.create = function (BaseStore, host, port, db) {
6774
var that = this;
6875

6976
client.hgetall(path, function (err, res) {
77+
logErr(err);
7078
that.notify(cb, expand(res) || undefined);
7179
});
7280
}
@@ -81,6 +89,7 @@ exports.create = function (BaseStore, host, port, db) {
8189
keys.forEach(function (key) { multi.hgetall(key); });
8290

8391
multi.exec(function (err, values) {
92+
logErr(err);
8493
if (err || values.length === 0) {
8594
that.notify(cb);
8695
return;
@@ -102,6 +111,7 @@ exports.create = function (BaseStore, host, port, db) {
102111
var that = this;
103112

104113
client.keys("*", function (err, keys) {
114+
logErr(err);
105115
if (err || keys.length === 0) {
106116
that.notify(cb, {});
107117
return;
@@ -114,6 +124,7 @@ exports.create = function (BaseStore, host, port, db) {
114124
keys.forEach(function (key) { multi.hgetall(key); });
115125

116126
multi.exec(function (err, values) {
127+
logErr(err);
117128
keys.forEach(function (key, index) {
118129
routes[key] = expand(values[index]);
119130
});
@@ -128,6 +139,7 @@ exports.create = function (BaseStore, host, port, db) {
128139
var that = this;
129140

130141
client.hmset(path, scrub(data), function (err, res) {
142+
logErr(err);
131143
that.notify(cb);
132144
});
133145
}
@@ -138,6 +150,7 @@ exports.create = function (BaseStore, host, port, db) {
138150

139151
this.get(path, function (current) {
140152
client.hmset(path, Object.assign(current, scrub(data)), function (err, res) {
153+
logErr(err);
141154
that.notify(cb);
142155
});
143156
});
@@ -148,6 +161,7 @@ exports.create = function (BaseStore, host, port, db) {
148161
var that = this;
149162

150163
client.del(path, function (err, res) {
164+
logErr(err);
151165
that.notify(cb);
152166
});
153167
}
@@ -157,6 +171,7 @@ exports.create = function (BaseStore, host, port, db) {
157171
var that = this;
158172

159173
client.exists(path, function (err, res) {
174+
logErr(err);
160175
that.notify(cb, res === 1);
161176
});
162177
}

0 commit comments

Comments
 (0)