logger.test.js — fastify Source File
Architecture documentation for logger.test.js, a javascript file in the fastify codebase.
Entity Profile
Relationship Graph
Source Code
'use strict'
const { test } = require('node:test')
const Fastify = require('../..')
const loggerUtils = require('../../lib/logger-factory')
const { serializers } = require('../../lib/logger-pino')
test('time resolution', t => {
t.plan(2)
t.assert.strictEqual(typeof loggerUtils.now, 'function')
t.assert.strictEqual(typeof loggerUtils.now(), 'number')
})
test('The logger should add a unique id for every request', (t, done) => {
const ids = []
const fastify = Fastify()
fastify.get('/', (req, reply) => {
t.assert.ok(req.id)
reply.send({ id: req.id })
})
fastify.listen({ port: 0 }, err => {
t.assert.ifError(err)
const queue = new Queue()
for (let i = 0; i < 10; i++) {
queue.add(checkId)
}
queue.add(() => {
fastify.close()
done()
})
})
function checkId (done) {
fastify.inject({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
}, (err, res) => {
t.assert.ifError(err)
const payload = JSON.parse(res.payload)
t.assert.ok(ids.indexOf(payload.id) === -1, 'the id should not be duplicated')
ids.push(payload.id)
done()
})
}
})
test('The logger should not reuse request id header for req.id', (t, done) => {
const fastify = Fastify()
fastify.get('/', (req, reply) => {
t.assert.ok(req.id)
reply.send({ id: req.id })
})
fastify.listen({ port: 0 }, err => {
t.assert.ifError(err)
fastify.inject({
method: 'GET',
// ... (104 more lines)
Domain
Subdomains
Source
Frequently Asked Questions
What does logger.test.js do?
logger.test.js is a source file in the fastify codebase, written in javascript. It belongs to the CoreKernel domain, InstanceFactory subdomain.
What functions are defined in logger.test.js?
logger.test.js defines 3 function(s): Queue, add, run.
Where is logger.test.js in the architecture?
logger.test.js is located at test/internals/logger.test.js (domain: CoreKernel, subdomain: InstanceFactory, directory: test/internals).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free