Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: accept a boolean param called eg "log" or "execute" #35

Open
nickleus opened this issue Oct 15, 2015 · 2 comments
Open

Comments

@nickleus
Copy link

var log = false;
console.log(log, "doesn't log to console");
log = true;
console.log(log, "does log to console");
...
var headerLogging = false;
var footerLogging = true;

function headerCode() {
// do stuff
console.log(headerLogging, "someObj",someObj);
// do more stuff
console.log(headerLogging, "anotherObj",anotherObj);
}

function footerCode() {
// do stuff
console.log(footerLogging, "someObj",someObj);
// do more stuff
console.log(footerLogging, "anotherObj",anotherObj);
}

would b extremely helpful, instead of having to comment out "console.log()" lines in my code.
or is there an existing/better way of doing this?

@past
Copy link

past commented Oct 15, 2015

It doesn't buy us much compared to:

shouldLog && console.log("shouldLog was true");

Others like to wrap console.log in a function that can be manipulated in runtime:

function log(shouldLog, ...params) {
    if (shouldLog) {
        console.log(...params);
    }
}

Also, changing an API in such a backwards incompatible way is always frowned upon.

@nickleus
Copy link
Author

@past (facepalm) brilliant, thx! this can b closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants