nodejs winston - Logging with multiple arguments

I was trying to use winston for logging, but I am seeing that if I want to get the data with 2 arg, then I am getting the log, but if I want to get 3 arguments, then I am not getting the data,

Ex:

logger = new (winston.Logger)({
transports: [
   new (winston.transports.Console)({colorize : true, timestamp:true}),
 ]
});

Now trying to get the log as below:

 1. logger.info("We got the data %s, %d", data, port);
 O/P: We got the data %s, %d  => No data and port value
 2. logger.info("We got the data, port", data, port);
 O/P: We got the data, port   => No data and port value
 3. logger.info("We got the data", data);
 ===> Getting the data correctly.

Can you please let me know what I was missing in 1, 2 or does winston not log the data in case 1 & 2 really?

You are assuming there is a varargs style API, but there is not. The full API is level, msg, meta, callback, but when you use one of the methods that is the level, then it's just msg, meta, callback. You need to construct a single meta object and pass that.

https://github.com/flatiron/winston/blob/master/lib/winston/logger.js#L115

//
// ### function log (level, msg, [meta], callback)
// #### @level {string} Level at which to log the message.
// #### @msg {string} Message to log
// #### @meta {Object} **Optional** Additional metadata to attach
// #### @callback {function} Continuation to respond to when complete.
// Core logging method exposed to Winston. Metadata is optional.
//

https://github.com/flatiron/winston#logging-with-metadata

I worked around this by wrapping the winston functions, and using the wrapper. I hope there's a better solution for this by now.

var logger = new (winston.Logger)({
        transports:[new (winston.transports.Console)({ json : false, timestamp : true, level : 0, colorize : true}),
                    new (winston.transports.File)({ filename: filepath, json : false, timestamp : true, level : 0, colorize: true })]
    });

// pass in function arguments object and returns string with whitespaces
function argumentsToString(v){
    // convert arguments object to real array
    var args = Array.prototype.slice.call(v);
    for(var k in args){
        if (typeof args[k] === "object"){
            // args[k] = JSON.stringify(args[k]);
            args[k] = util.inspect(args[k], false, null, true);
        }
    }
    var str = args.join(" ");
    return str;
}


    // wrapping the winston function to allow for multiple arguments
    var wrap = {};
    wrap.info = function () {
        logger.log.apply(logger, ["info", argumentsToString(arguments)]);
    };

    wrap.error = function () {
        logger.log.apply(logger, ["error", argumentsToString(arguments)]);
    };

    wrap.warn = function () {
        logger.log.apply(logger, ["warn", argumentsToString(arguments)]);
    };

    wrap.debug = function () {
        logger.log.apply(logger, ["debug", argumentsToString(arguments)]);
    };

/// then return wrap as is it was your logger. /// and use like log.info(1,2,3,4,"foo","bar");