This repository was archived by the owner on Jul 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: disable trace logging by default (#32)
Disable trace logging unless the user has explicitly enabled it
- Loading branch information
1 parent
6e5ed97
commit 47915fe
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,55 @@ | ||
import { expect } from 'aegir/chai' | ||
import { logger } from '../src/index.js' | ||
import debug from 'debug' | ||
|
||
describe('logger', () => { | ||
it('creates a logger', () => { | ||
const log = logger('hello') | ||
|
||
expect(log).to.be.a('function') | ||
expect(log).to.a.property('enabled').that.is.not.true() | ||
expect(log).to.have.property('error').that.is.a('function') | ||
expect(log).to.have.property('enabled') | ||
expect(log).to.have.nested.property('error.enabled').that.is.not.true() | ||
expect(log).to.have.property('trace').that.is.a('function') | ||
expect(log).to.have.nested.property('trace.enabled').that.is.not.true() | ||
}) | ||
|
||
it('creates a logger with logging enabled', () => { | ||
debug.enable('enabled-logger') | ||
|
||
const log = logger('enabled-logger') | ||
|
||
expect(log).to.be.a('function') | ||
expect(log).to.a.property('enabled').that.is.true() | ||
expect(log).to.have.property('error').that.is.a('function') | ||
expect(log).to.have.nested.property('error.enabled').that.is.not.true() | ||
expect(log).to.have.property('trace').that.is.a('function') | ||
expect(log).to.have.nested.property('trace.enabled').that.is.not.true() | ||
}) | ||
|
||
it('creates a logger with logging and errors enabled', () => { | ||
debug.enable('enabled-with-error-logger*') | ||
|
||
const log = logger('enabled-with-error-logger') | ||
|
||
expect(log).to.be.a('function') | ||
expect(log).to.a.property('enabled').that.is.true() | ||
expect(log).to.have.property('error').that.is.a('function') | ||
expect(log).to.have.nested.property('error.enabled').that.is.true() | ||
expect(log).to.have.property('trace').that.is.a('function') | ||
expect(log).to.have.nested.property('trace.enabled').that.is.not.true() | ||
}) | ||
|
||
it('creates a logger with trace enabled', () => { | ||
debug.enable('enabled-with-trace-logger*,*:trace') | ||
|
||
const log = logger('enabled-with-trace-logger') | ||
|
||
expect(log).to.be.a('function') | ||
expect(log).to.a.property('enabled').that.is.true() | ||
expect(log).to.have.property('error').that.is.a('function') | ||
expect(log).to.have.nested.property('error.enabled').that.is.true() | ||
expect(log).to.have.property('trace').that.is.a('function') | ||
expect(log).to.have.nested.property('trace.enabled').that.is.true() | ||
}) | ||
}) |