-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Tagged logging #10
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
812d3bb
fix: Make each log count assertion (error, log, debug, warn) optional
mike-north 5cb8600
fix: test printer captures all arguments passed to log, debug, etc...…
mike-north 8fba2b3
feat: tagged logging
mike-north 90ba2e7
Merge branch 'master' into tagging
lisaychuang ba7ba41
fix: respond to @lisaychuang's feedback
mike-north 96e2dfd
Merge branch 'tagging' of github.com:mike-north/bite-log into tagging
mike-north 752a288
fix: minor TS syntax fixes
mike-north File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Logger from 'bite-log'; | ||
import { logCountAssert, makeTestPrinter } from './test-helpers'; | ||
|
||
QUnit.module('Tagged logging'); | ||
|
||
QUnit.test( | ||
'Pushing a tag results in the log mesages being prefixed', | ||
assert => { | ||
const printer = makeTestPrinter(); | ||
const logger = new Logger(4, printer); | ||
logger.log('hello'); // "hello" | ||
logger.log('world'); // "world" | ||
logger.pushPrefix('foo'); | ||
logger.log('goodbye'); // "[foo]: goodbye" | ||
logger.log('mars'); // "[foo]: mars" | ||
logger.pushPrefix('bar'); | ||
logger.log('(and saturn!)'); // "[foo][bar]: (and saturn)!" | ||
logger.popPrefix(); | ||
logger.popPrefix(); | ||
logger.log('but not pluto'); // "but not pluto" | ||
logCountAssert( | ||
{ message: 'after logging four things', assert, printer }, | ||
{ l: 6 } | ||
); | ||
const logs = printer.messages.log; | ||
assert.ok(logs[0].join('').indexOf('foo') < 0, 'First message has no "foo" tag'); | ||
assert.ok(logs[1].join('').indexOf('foo') < 0, 'Second message has no "foo" tag'); | ||
assert.ok(logs[2].join('').indexOf('foo') >= 0, 'Third message has a "foo" tag'); | ||
assert.ok(logs[3].join('').indexOf('foo') >= 0, 'Fourth message has a "foo" tag'); | ||
assert.ok(logs[4].join('').indexOf('foo') >= 0, 'Fifth message has a "foo" tag'); | ||
assert.ok(logs[4].join('').indexOf('bar') >= 0, 'Fifth message has a "bar" tag'); | ||
assert.ok(logs[5].join('').indexOf('foo') < 0, 'Sixth message has no "foo" tag'); | ||
} | ||
); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the array is empty and there are no more Prefixes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have confirmed that it will not be harmful, and consistent with what developers expect from
[].pop();