Last active
August 25, 2018 19:31
-
-
Save hbarcelos/f5274dc0233357a1de1d216d5b06eb9b to your computer and use it in GitHub Desktop.
Contextual Logger - Keep context from method call
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
diff --git a/logger.test.js b/logger.test.js | |
index 8f89251..a841156 100644 | |
--- a/logger.test.js | |
+++ b/logger.test.js | |
@@ -13,3 +13,19 @@ loggerMethodUseCases.forEach(({ input, expected }) => { | |
expected | |
); | |
}); | |
+ | |
+test(`Properly logs message with context object`, async t => { | |
+ const stream = parseJSONStream(); | |
+ const gen = streamToGenerator(stream); | |
+ const logger = createLogger({}, stream); | |
+ | |
+ const context = { dummy: 'value' }; | |
+ const message = 'foo'; | |
+ | |
+ logger.info(context, message); | |
+ | |
+ const entry = await gen.next().value; | |
+ | |
+ t.deepEqual(entry.dummy, context.dummy); | |
+ t.deepEqual(entry.msg, message); | |
+}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment