Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Allow 'error' prefix #19

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions log.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,6 @@ log.addLevel('http', 3000, { fg: 'green', bg: 'black' })
log.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN')
log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!')
log.addLevel('silent', Infinity)

// allow 'error' prefix
log.on('error', function(){})
9 changes: 8 additions & 1 deletion test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var resultExpect =
'\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[31m\u001b[40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m and maybe a stack.\n',
'\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u001b[31m\u001b[40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m \n',
'\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u0007noise\u001b[0m\u001b[35m\u001b[0m LOUD NOISES\n',
'\u001b[0m\u001b[37m\u001b[40mnpm\u001b[0m \u001b[0m\u0007noise\u001b[0m \u001b[0m\u001b[35merror\u001b[0m erroring\n',
'\u001b[0m' ]

var logPrefixEventsExpect =
Expand Down Expand Up @@ -161,7 +162,12 @@ var logEventsExpect =
level: 'noise',
prefix: false,
message: 'LOUD NOISES',
messageRaw: [ 'LOUD NOISES' ] } ]
messageRaw: [ 'LOUD NOISES' ] },
{ id: 23,
level: 'noise',
prefix: 'error',
message: 'erroring',
messageRaw: [ 'erroring' ] } ]

var Stream = require('stream').Stream
var s = new Stream()
Expand Down Expand Up @@ -217,6 +223,7 @@ tap.test('basic', function (t) {
'and maybe a stack.\n')
log.addLevel('noise', 10000, {beep: true})
log.noise(false, 'LOUD NOISES')
log.noise('error', 'erroring')

t.deepEqual(result.join('').trim(), resultExpect.join('').trim(), 'result')
t.deepEqual(log.record, logEventsExpect, 'record')
Expand Down