Skip to content
Zero config queries logger for knex
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
flow-typed/npm
src
.babelrc
.eslintrc
.flowconfig
.gitignore
LICENSE.md
README.md
package.json
yarn.lock

README.md

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

You can’t perform that action at this time.