FAQ
Thanks for all the feedback guys, still trying to learn all the intricacies
of the module system, and just the best patterns to use. I remember reading
somewhere (I'll have to dig it up, though Crockford comes to mind), that
the the "createLogger()" type of pattern is the preferred one. I see it in
a lot of libraries. Never really saw the point in that myself, seems more
restrictive.

What I basically want to do is have the main exports be the instantiated
object (of anything), but a static init() function. Just gotta play with
all your suggestions and see how it works. Thanks guys!



On Sat, Mar 23, 2013 at 9:08 PM, Rick Waldron wrote:




On Sat, Mar 23, 2013 at 8:29 PM, Ilya Shaisultanov <
ilya.shaisultanov@gmail.com> wrote:
Weird


module.exports = Logger;
// ...

module.exports.createLogger = function createLogger(options) {


return new Logger(options);


};


Maybe compatibility with old API?

Hilarious. I control-F'ed for "createLogger". All of the README uses
"createLogger". Makes me happy to see that I was at least half wrong and
also that you could use Mikeal's suggestion for "path of nicest api".

Anyway, now I'm wondering why module.exports is being set to the
constructor function object itself, AND THEN expando properties are
defined. Why not define them as static properties on Logger and have _one_
export?

Again, feel free to ignore me. (I'm turning into Statler and (or) Waldorf).

Rick


On Saturday, March 23, 2013 8:25:03 PM UTC-4, Mikeal Rogers wrote:

var logger = bunyan();

:)

-Mikeal

On Mar 23, 2013, at 5:22PM, Rick Waldron wrote:

I might be half-trolling here...

On Fri, Mar 22, 2013 at 1:50 AM, Nabeel S. wrote:


var logger = bunyan.createLogger(...);
Why do module authors make gross factory APIs?

Instead of wrapping the export in this icky "createLogger" method, that
doesn't do _anything_ (one assumes a factory exists to provide some
additional layer of logic over the base constructor, or else what is the
point?), why not export the constructor?

var logger = new bunyan.Logger();

Yay, much nicer.

Feel free to completely ignore me.

Rick




--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/**node/wiki/Mailing-List-*
*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 nod...@googlegroups.com

To unsubscribe from this group, send email to
nodejs+un...@**googlegroups.com

For more options, visit this group at
http://groups.google.com/**group/nodejs?hl=en?hl=en<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 nodejs+un...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
.




--
--
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
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 nodejs+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
--
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
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 a topic in the
Google Groups "nodejs" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/nodejs/peTzWLT9gpQ/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to
nodejs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
--
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
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 nodejs+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 11 of 18 | next ›
Discussion Overview
groupnodejs @
categoriesnodejs
postedMar 22, '13 at 5:50a
activeMar 25, '13 at 10:27a
posts18
users8
websitenodejs.org
irc#node.js

People

Translate

site design / logo © 2022 Grokbase