-1

I am using Winston (Logger for nodejs).

In my script i call:

log.error("my error", {input: [1,2]});

console show me:

error: my error input=[1, 2]

What i want to do: don' call at log.error(null)

In some functions i dynamically call the log.error with a variable and dont know if the variable are NULL or have a value. If i call log.error(null) he write "error:" to the console.

I tried with this:

log.error = (function () {
    var old = log.error;

    return function newerror() {
        if (arguments.length !== 0) {
            old(arguments);
        }
    };
})();

But now i got:

error: 0=my error, input=[1, 2]

as output.

My Question

how i can call the log.error() function with die arguments given (arguments-var in javascript is a object).

Function style:

function foo(arg1,arg2,...)

I want something like:

foo.call(myargumentsobj);
mdunisch
  • 3,627
  • 5
  • 25
  • 41

1 Answers1

0

oh i got it:

old.apply(this, arguments);
mdunisch
  • 3,627
  • 5
  • 25
  • 41