[Feedhenry-raincatcher] Raincatcher logger

Michal Ogrodniczak mogrodni at redhat.com
Thu Mar 23 12:05:06 UTC 2017


Hi all,

I'm creating JIRA's following up on selecting logger lib spike. I've just
hit in an issue where I'm not sure on implementation details and wanted to
get team's input on this.

What I want to do:
- require and configure Bunyan in the demo app
- have our `fh-whm-*` dependencies/modules use that logger
- in my opinion, we should use singleton pattern as to not having multiple
instances of a logger and potentially polluting event loop (esp when we
consider transports, rotates etc.)


The question I have:
How do we implement singleton pattern?
- similar implementation to the mediator? a.i pass it into other modules on
`require`/`init`?, I'm not a big fan of this solution, I think it adds
complexity and forces behaviour.
- `require` singleton provided by npm caching? I like this approach but it
has few gotchas where the object is not a singleton [are-node-js-modules-
singletons](https://medium.com/@lazlojuly/are-node-js-modules-singletons-
764ae97519af#.yiayddmm1)
-- mix of require and setter, personally I like this solution
https://github.com/feedhenry/fh-mbaas-client/blob/
e7fcadb88884865abc8c57b789c1570bef7cef80/lib/logger/logger.js

Any comments and suggestions are welcomed


Michal

-- 
Michal Ogrodniczak
Associate Software Engineer, Red Hat Mobile

mobile: *+353 83 334 5030 <//+353833345030> *
slack: *@mogrodni*
mail: *mogrodni at redhat.com <mogrodni at redhat.com>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/feedhenry-raincatcher/attachments/20170323/4d89e8b8/attachment.htm>


More information about the Feedhenry-raincatcher mailing list