Skip to content

Instantly share code, notes, and snippets.

@hbarcelos
Last active August 25, 2018 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hbarcelos/f5274dc0233357a1de1d216d5b06eb9b to your computer and use it in GitHub Desktop.
Save hbarcelos/f5274dc0233357a1de1d216d5b06eb9b to your computer and use it in GitHub Desktop.
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