[debug] hot swappable logging for verbose mode #35

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

Projects

None yet

4 participants

@perezd
Collaborator
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
Owner
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
ghost commented Nov 5, 2011

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

@dscape
Owner
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
Collaborator
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
Collaborator
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

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
Collaborator
perezd commented Nov 7, 2011

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

@indexzero

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

@perezd
Collaborator
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
Owner
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)

@perezd perezd was assigned Nov 8, 2011
@perezd
Collaborator
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
Owner
dscape commented Nov 11, 2011

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

@perezd
Collaborator
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
Owner
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
Collaborator
perezd commented Nov 11, 2011

its pretty rad! awesome find!

@dscape
Owner
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
Owner
dscape commented Dec 29, 2011
@dscape dscape closed this Jan 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment