Avoid using globals if possible... A logger module like @greelgorke 
suggested is probably your best option. For exposing objects to modules in 
general, check out this pattern: 

// mymodule.js
module.exports = function (myObj) {
  // extend myObj
}

-----

// app.js
require("./mymodule")(myObj);

It's used in some Express apps so route modules can extend the app with 
additional routes.

On Tuesday, January 21, 2014 4:33:38 PM UTC-5, Kevin Ingwersen wrote:
>
> Hello there. 
>
> I am currently thinking about implementing npmlog into one of my 
> applications. It looks smooth and very nice. However, I would like to do 
> that for console.log too. Like: 
>
> console__log=console.log; 
> console.log=function(msg) { 
>         require(„npmlog“).info(null, msg); 
> } 
>
> … or, kinda like that. But - what I really ment is, if I had this 
> customized console object, how would I expose it to a node module? The 
> current way I would think is: 
>
> var m = require(„module_xyz“); 
> m.console=console; 
> // and from within the module: 
> m.console.log(…); 
>
> … Is there a cleaner way to do that? Do GLOBALS make something different 
> here? 
>
> Kind regards, Ingwie

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to