child-logger-factory.test.js — fastify Source File
Architecture documentation for child-logger-factory.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('..')
test('Should accept a custom childLoggerFactory function', (t, done) => {
t.plan(4)
const fastify = Fastify()
fastify.setChildLoggerFactory(function (logger, bindings, opts) {
t.assert.ok(bindings.reqId)
t.assert.ok(opts)
this.log.debug(bindings, 'created child logger')
return logger.child(bindings, opts)
})
fastify.get('/', (req, reply) => {
req.log.info('log message')
reply.send()
})
t.after(() => fastify.close())
fastify.listen({ port: 0 }, err => {
t.assert.ifError(err)
fastify.inject({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
}, (err, res) => {
t.assert.ifError(err)
done()
})
})
})
test('Should accept a custom childLoggerFactory function as option', (t, done) => {
t.plan(4)
const fastify = Fastify({
childLoggerFactory: function (logger, bindings, opts) {
t.assert.ok(bindings.reqId)
t.assert.ok(opts)
this.log.debug(bindings, 'created child logger')
return logger.child(bindings, opts)
}
})
fastify.get('/', (req, reply) => {
req.log.info('log message')
reply.send()
})
t.after(() => fastify.close())
fastify.listen({ port: 0 }, err => {
t.assert.ifError(err)
fastify.inject({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
}, (err, res) => {
// ... (69 more lines)
Source
Frequently Asked Questions
What does child-logger-factory.test.js do?
child-logger-factory.test.js is a source file in the fastify codebase, written in javascript.
Where is child-logger-factory.test.js in the architecture?
child-logger-factory.test.js is located at test/child-logger-factory.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free