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

Comment up console methods #1279

Closed
devinrhode2 opened this issue Dec 28, 2012 · 5 comments
Closed

Comment up console methods #1279

devinrhode2 opened this issue Dec 28, 2012 · 5 comments

Comments

@devinrhode2
Copy link
Contributor

Somethin like:

var methods = [
'log', 'error', 'warn',
'dir',               // print object level view, showing prototype methods
'time', 'timeEnd',   // console.time('op') ... console.timeEnd('op') => 12ms
'trace',             // print current stack
'assert',            // oh plz (takes boolean)
'group', 'groupEnd', // place logs in a collapsable unit
'groupCollapsed',    // same as group, but opens as collapsed by default (logs will be hidden)

'profile', 'profileEnd', // oh sure these methods don't get a good comment

//lmgtfy.com/?q=console.count
'count', 'timeStamp', 'markTimeline',

// identical to console.log (in chrome)
'info', 'debug', 'dirxml'

// Not defined in chrome
'clear', 'exception', 'table'
];
...

I tried to put them in order of usefulness. Log is probably the most used method, so that's first.

Feel free to tweak and edit it up, I nearly have a PR for this when we're ready

@necolas
Copy link
Member

necolas commented Dec 28, 2012

Is this really necessary? Given that the purpose of the function is just to protect against stray console methods when they aren't supported, I think comments explaining the use of each method in this context may be code-smell.

@devinrhode2
Copy link
Contributor Author

To help educate developers about these methods. which definitely can make
your life easier, I think it's helpful.

On Fri, Dec 28, 2012 at 6:47 AM, Nicolas Gallagher <notifications@github.com

wrote:

@necolas
Copy link
Member

necolas commented Dec 28, 2012

IMO, this isn't the place to do it.

@devinrhode2
Copy link
Contributor Author

I think it can be really helpful. For example, I actually didn't discover console.trace until I saw it here and searched it. The only other way I know to get stack traces is to console.log(Error('asdf'))

...or wait it's actually console.log(Error('asdf').stack))

Lots of people use html5 boilerplate, and as what I've taken from @paulirish, a key thing is to make developers think, hence window.jQuery || document.write("jquery")

Equipping developers with this knowlege can only help. We could at least link to an article outlining all the console methods.

@necolas
Copy link
Member

necolas commented Dec 30, 2012

Thanks for the suggestion, Devin, but I think we should pass on this. That plugins.js function has a specific purpose that's orthogonal to explaining what every console method does in various contexts. Including those comments feels like "code smell". If the project is meant to set an example, then inappropriately commented code is one I'd like to avoid. Finding out what specific console methods are for, as you did, is just a simple google query away.

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