From 6569ff75de3ca1a8278673c61b35351342691924 Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Sun, 10 Oct 2021 19:57:48 +0000 Subject: [PATCH] ctx: Add missing log to context --- flaska.mjs | 1 + test/flaska.in.test.mjs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/flaska.mjs b/flaska.mjs index 2201eb5..eafbbc0 100644 --- a/flaska.mjs +++ b/flaska.mjs @@ -371,6 +371,7 @@ export class Flaska { } let ctx = { + log: this.log, req: req, res: res, method: req.method, diff --git a/test/flaska.in.test.mjs b/test/flaska.in.test.mjs index c275658..7db2183 100644 --- a/test/flaska.in.test.mjs +++ b/test/flaska.in.test.mjs @@ -125,7 +125,9 @@ t.describe('#requestStart()', function() { const assertMethod = 'test' const assertPath = '/test/me' const assertSearch = '?asdf=test' - let flaska = new Flaska({}, faker) + const assertLog = { info: function() {}, error: function() {} } + let flaska = new Flaska({ log: assertLog }, faker) + assert.strictEqual(flaska.log, assertLog) flaska.compile() flaska.routers.test = { @@ -148,6 +150,7 @@ t.describe('#requestStart()', function() { assert.strictEqual(ctx.body, null) assert.strictEqual(ctx.type, null) assert.strictEqual(ctx.length, null) + assert.strictEqual(ctx.log, assertLog) cb() } catch (err) { cb(err) } }