Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina committed Jan 13, 2025
2 parents e04fa49 + c917562 commit 7663b1b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion debug.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const util = require('util')

module.exports = debug

function debug (namespace) {
Expand All @@ -16,7 +18,8 @@ function debug (namespace) {
function disabled () {}
disabled.enabled = false
function enabled () {
return log.apply(logger, arguments)
const message = util.format.apply(util, arguments) // this is how debug.js formats argeuments
return log.apply(logger, [message])
}
enabled.enabled = true

Expand Down
17 changes: 17 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,20 @@ test('does not invalidate strict mode', (t) => {
t.equal(require('./fixtures/strict-mode'), true)
t.end()
})

test('Process all arguments debug.js style', (t) => {
const testOptions = { option1: 'value1' }
process.env.DEBUG = 'ns1'
const pinoDebug = require('../')
const stream = through((line, _, cb) => {
const obj = JSON.parse(line)
const expectedMsg = "test { option1: 'value1' }"
t.equal(obj.msg, expectedMsg)
t.equal(obj.ns, 'ns1')
t.end()
})
pinoDebug(require('pino')({ level: 'debug' }, stream))
const debug = require('debug')

debug('ns1')('test', testOptions)
})

0 comments on commit 7663b1b

Please sign in to comment.