Skip to content

Logging Module

Hoie Kim edited this page Apr 23, 2020 · 10 revisions

Intro

Instead of your typical console.log, we use a logging component.

How to use

  1. Logging module is in lib folder. Import lib/log.js and pass __filename in as an argument.

    • Exmaple: const logger = require('./lib/log')(__filename)
  2. Replace console.log to logger.info.

    • Exmaple: logger.info('function has successfully run')
  3. You can add logger with any information you want to log and apply different levels according to its importance.

    Inportance Level Example
    0 Error logger.error('an error has occured')
    1 Warn logger.warn('warning!')
    2 Info logger.info('function has successfully run')

Output

image

Clone this wiki locally