Giter Site home page Giter Site logo

Comments (6)

jonnyreeves avatar jonnyreeves commented on July 22, 2024

Adding a what...?! Don't leave me hanging!

from js-logger.

hepiyellow avatar hepiyellow commented on July 22, 2024

Oops, forgot to wrap <script> in code back ticks. Edited original comment.

from js-logger.

timdiacon avatar timdiacon commented on July 22, 2024

+1 on this please!

I'd love to load into my modules in require.js but can't work out how to do it :-(

from js-logger.

jonnyreeves avatar jonnyreeves commented on July 22, 2024

You just need to make a require call for the js-logger module:

// CommonJS import
var jsLogger = require('js-logger');

// Usage.
var namedLogger = jsLogger.get('named-logger');
namedLogger.info("hello world!")

If you are using ES6 modules, you can use the import keyword:

import jsLogger from 'js-logger';

I have personally used JSLogger with browserify and webpack; I'm pretty sure I had it working with requirejs back in the day (:

from js-logger.

timdiacon avatar timdiacon commented on July 22, 2024

Thanks for reply, so I guess I should be using either browserify or webpack ;-)

However, and this is probably more a lack of understanding about how requirejs works...
How do I set useDefaults() on the logger in my main.js and then have that setting persist on instances of the logger I require into my modules?

The only way I could make it work was by creating a wrapper module around jslogger which has a getter to retrieve the logger instance but I'm guessing that is not what I'm supposed to be doing?

from js-logger.

jonnyreeves avatar jonnyreeves commented on July 22, 2024

If requirejs works the same as browserify and webpack; then modules are statically imported (in the java sense), so mutations made in one place will be picked up elsewhere, ie: you can import jsLogger in your entrypoint and invoke useDefaults() after which all subsequent invocation of jsLogger will be configured accordingly.

from js-logger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.