1.0.4 • Published 7 years ago

fn-logger v1.0.4

Weekly downloads
17
License
-
Repository
github
Last release
7 years ago

FUNCTION LOGGER

A JavaScript logging utility that prints the name of the function from where it is called with an assigned pretty color.

  • It works in both node and browser environments;
  • Supported browsers are Chrome and Opera

RUN:

  npm install fn-logger --save-dev

USAGE

  /** using es6 modules **/
  import logger from 'fn-logger'
  
  /** using commonJS modules **/
  const logger = require('fn-logger')
  
  /** using script tag **/
  <script src="node_modules/fn-logger/index.js"></script>
  
  function animal(type) {
    logger(type)
  }
    
  animal({type: 'cat', color: 'black'})

Browser
Alt text

Node
Alt text

Or import at the root of your project and then save to window to use without having to import it into every file:

    /** using es6 modules in browser environment **/  
    import logger from 'fn-logger'
    window.logger = logger //or window.whateverName = logger
     
     /** using commonJS in node environment **/ 
    const logger= require('fn-logger')
    global.logger = logger
    
    class Cat{
      constructor(name, age, breed) {
        this.name = name
        this.age = age
        this.breed = breed
      }
      getName() {
        logger('name -->', this.name)
      }
      getAge() {
        logger('age -->', this.age)
      }
      isBreed(type) {
        const isBreed = this.breed === type
        logger(`is breed ${type} ${isBreed}`)
      }
    }
    
    const cat = new Cat('Pippa', 1, 'siamese')
    cat.getName()
    cat.getAge()
    cat.isBreed('siamese')

Browser
Alt text

Node
Alt text

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago