Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Contextual Logger - Keep context from method call
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
You can’t perform that action at this time.