Browse files

don't throw when first argument isn't a string

  • Loading branch information...
1 parent acc2444 commit b8cf35cd7c766d36c412d542c673ac4e6af64172 @fb55 fb55 committed Jul 27, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/winston/common.js
View
8 lib/winston/common.js
@@ -266,7 +266,13 @@ exports.serialize = function (obj, key) {
// uses the original array and removes items as it proceeds
//
exports.format = function (arr) {
- return arr.shift().replace(/%[sdj%]/g, function (x){
+ var msg = arr.shift();
+
+ if (typeof msg !== "string") {
+ return msg;
+ }
+
+ return msg.replace(/%[sdj%]/g, function (x){
switch (x.charAt(1)) {
case "j": return JSON.stringify(arr.shift());
case "s": return String(arr.shift());

0 comments on commit b8cf35c

Please sign in to comment.