Skip to content
This repository has been archived by the owner on Nov 5, 2018. It is now read-only.

[debug] hot swappable logging for verbose mode #35

Closed
perezd opened this issue Nov 4, 2011 · 17 comments
Closed

[debug] hot swappable logging for verbose mode #35

perezd opened this issue Nov 4, 2011 · 17 comments
Assignees
Milestone

Comments

@perezd
Copy link
Contributor

perezd commented Nov 4, 2011

Verbose mode can be incredibly useful for debugging even in production, instead of just throwing console.log all over the place, we could allow the caller to specify their own custom function for capturing the logs, if a user provides a transport, always pipe to it, otherwise if you're in testing mode, just have that function be console.log

Thoughts?

@dscape
Copy link
Contributor

dscape commented Nov 5, 2011

Sounds like a winner to me
On Nov 4, 2011 11:49 PM, "Derek Perez" <
reply@reply.github.com>
wrote:

Verbose mode can be incredibly useful for debugging even in production,
instead of just throwing console.log all over the place, we could allow the
caller to specify their own custom function for capturing the logs, if a
user provides a transport, always pipe to it, otherwise if you're in
testing mode, just have that function be console.log

Thoughts?


Reply to this email directly or view it on GitHub:
#35

@ghost
Copy link

ghost commented Nov 5, 2011

I guess you mean something like https://github.com/indexzero/winston?

@dscape
Copy link
Contributor

dscape commented Nov 6, 2011

I think so too, I'de be very interested in this feature.

Adding @pgte and @indexzero for possible input.

@perezd do you have some code doing this? Please keep nano in a single file
as eventually I will migrate translate the library into the client side too.

On Sat, Nov 5, 2011 at 4:59 PM, tarantoga <
reply@reply.github.com>wrote:

I guess you mean something like https://github.com/indexzero/winston?


Reply to this email directly or view it on GitHub:
#35 (comment)

@pgte
Copy link
Contributor

pgte commented Nov 6, 2011

I usually provide a .verbose() function that accepts a function that will accept one string arg, so you can do stuff like .verbose(console.log).
Also, I think you should provide this at the db level, not higher.

@perezd
Copy link
Contributor Author

perezd commented Nov 6, 2011

I've not added any code yet, wanted to start a discussion on the API, first. Definitely will keep it to one file, I estimate less than 15 lines of code :P

@indexzero
Copy link

I'm still pulling for a cradle rewrite, but I'd be happy to help where I can. A small request: comma-first makes me die a little inside

@perezd
Copy link
Contributor Author

perezd commented Nov 7, 2011

as a former cradle user, I far prefer this API, personally. Not sure how they are related?

@indexzero
Copy link

Just a question of using my constrained resources on two couchdb libraries

@perezd
Copy link
Contributor Author

perezd commented Nov 7, 2011

I'm happy to work on this project, I feel like its a pretty simplistic change, and something I personally need.

@dscape
Copy link
Contributor

dscape commented Nov 8, 2011

@perezd go for it :) looking forward to the commits. right now im checking all my public libs work on node 0.6.0 so might see some action on nano soon.

@indexzero comma first was just to help developers make less mistakes. Personally I always jshint the code anyway.

@perezd maybe a sample with winston integration would be a nice goal :) also we should be trying for 1.0 but I'm waiting on a stand alone ajax implementation to be available since I want nano in the browser to be independent from jQuery. Thoughts? Yogurt? (I'm having yogurt)

@ghost ghost assigned perezd Nov 8, 2011
@perezd
Copy link
Contributor Author

perezd commented Nov 8, 2011

the most basic implementation that I'd like to give is piping to STDOUT/console.log, from there, anyone should be able to take it and run with it. Its on my short list of things to do!

@dscape
Copy link
Contributor

dscape commented Nov 11, 2011

Update, we actually need this to solve #36 cause tap hijacks stdout

@perezd
Copy link
Contributor Author

perezd commented Nov 11, 2011

excellent timing :) I'm not available to work on this particular issue right this moment (closing in on a milestone for day job), but my idea was to simply add a function call to every location that we're using console.log currently, and have that execute a function that is passed into the options hash of the nano constructor, if it exists, else, assign console.log to that option, if nothing is provided, and the NANO_ENV == "testing". If we're not in testing mode, and no capture function is specified, it can be piped to an empty function.

@dscape
Copy link
Contributor

dscape commented Nov 11, 2011

@perezd check travis, im super excited about having this work and knowing if something is broken. this is SUPER COOL

@perezd
Copy link
Contributor Author

perezd commented Nov 11, 2011

its pretty rad! awesome find!

@dscape
Copy link
Contributor

dscape commented Nov 14, 2011

I've started working on this in the browser branch. Was something that just needed to be done. Feedback is welcome, bonus point for showing me I'm an idiot and there's a better way to do it

@dscape
Copy link
Contributor

dscape commented Dec 29, 2011

More discussion here:
https://gist.github.com/d9eb8b0046fe7e29f526

@dscape dscape closed this as completed Jan 17, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants