1.2.3 • Published 5 years ago

flex-logger v1.2.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

Flex Logger

This package saves the logs inside the database. It is so simple and very easy to use. It's supports MongoDB and Mysql. You dont need a create a table. If there is no table , it is gonna create automatically.

Install

$ npm install flex-logger

Documentation

Quick Start

const FlexLogger = require('flex-logger')

Firstly you must create instance from flex logger class. Flex logger constructor can take arguments.

Mongodb:

const logger = new FlexLogger('mongodb', 'mongodb+srv://username:password@host/dbname', 'collectionName')

Mysql:

const logger = new FlexLogger('mysql', 'host=localhost;user=root;password=;dbname=test;', 'tableName')

There is five log level has automatically created. Each level has own unique number.

Now logging time

Logging

  FATAL: 0
  ERROR: 10
  WARN: 20
  INFO: 30
  DEBUG: 40
logger.fatal('fatal error')
logger.error('something is wrong')
logger.warn('it is gonna explode')
logger.info('i am super')
logger.debug('debug')

Event Handlers

It will be executed before the log save in the database.

Usage:

  logger.on(level, (msg, level) => {})

Example:

  logger.on(10, (msg, level) => {
    console.log('hello')
  })

Custom Levels

You can set a new log method with level number and name.

Usage:

  logger.setLevel('success', 100)

Example:

  logger.success('hello world')

For more example please look at the examples folder. And, just let me know when you find a bug.

Contributors

Lisence & Copyright

@ Furkan Demir

Lisenced under the MIT Lisence

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.0.0

5 years ago