Skip to content

khmm12/knex-tiny-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

knex-tiny-logger

Zero config queries logger for knex

Usage

Install the package:

$ yarn add knex-tiny-logger

Apply knex-tiny-logger to knex instance:

import createKnex from 'knex'
import knexTinyLogger from 'knex-tiny-logger'

const knexOptions = {} // Your knex config
const knex = createKnex(knexOptions)
knexTinyLogger(knex)

// alternative
// knex-tiny-logger returns knex instance
// so you can do like this
const knex = knexTinyLogger(createKnex(knexOptions))

Advanced usage

By default knex-tiny-logger uses console.log, but you can specify any logger which your prefer:

import createKnex from 'knex'
import knexTinyLogger from 'knex-tiny-logger'
import initDebug from 'debug'

const awesomeLogger = initDebug('my-project:knex')
const knexOptions = {} // Your knex config
const knex = createKnex(knexOptions)
knexTinyLogger(knex, { logger: awesomeLogger })

Also you can disable bindings:

knexTinyLogger(knex, { bindings: false })

License

MIT