Home / File/ logger.test-d.ts — fastify Source File

logger.test-d.ts — fastify Source File

Architecture documentation for logger.test-d.ts, a typescript file in the fastify codebase. 6 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  397a2db0_b4b0_15e1_235a_26b271edda06["logger.test-d.ts"]
  2bf9986b_b7fb_0c78_f075_72fbe6f4672b["fastify.js"]
  397a2db0_b4b0_15e1_235a_26b271edda06 --> 2bf9986b_b7fb_0c78_f075_72fbe6f4672b
  ee998eba_0ed8_8b67_66d6_d2f80d980a41["./logger"]
  397a2db0_b4b0_15e1_235a_26b271edda06 --> ee998eba_0ed8_8b67_66d6_d2f80d980a41
  1741b237_9033_f1d9_f91f_94ad04e621d4["tsd"]
  397a2db0_b4b0_15e1_235a_26b271edda06 --> 1741b237_9033_f1d9_f91f_94ad04e621d4
  bd94e3ff_2705_51a0_bac0_884f2c38b615["node:http"]
  397a2db0_b4b0_15e1_235a_26b271edda06 --> bd94e3ff_2705_51a0_bac0_884f2c38b615
  24b9af5c_d55d_734f_4144_7650cbc0bab9["node:fs"]
  397a2db0_b4b0_15e1_235a_26b271edda06 --> 24b9af5c_d55d_734f_4144_7650cbc0bab9
  db63796d_f2b5_6384_ef40_ca04c921a19e["pino"]
  397a2db0_b4b0_15e1_235a_26b271edda06 --> db63796d_f2b5_6384_ef40_ca04c921a19e
  style 397a2db0_b4b0_15e1_235a_26b271edda06 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { expectAssignable, expectDeprecated, expectError, expectNotAssignable, expectType } from 'tsd'
import fastify, {
  FastifyLogFn,
  LogLevel,
  FastifyBaseLogger,
  FastifyRequest,
  FastifyReply
} from '../../fastify'
import { Server, IncomingMessage, ServerResponse } from 'node:http'
import * as fs from 'node:fs'
import P from 'pino'
import { FastifyLoggerInstance, ResSerializerReply } from '../../types/logger'

expectType<FastifyBaseLogger>(fastify().log)

class Foo {}

['trace', 'debug', 'info', 'warn', 'error', 'fatal'].forEach(logLevel => {
  expectType<FastifyLogFn>(
    fastify<Server, IncomingMessage, ServerResponse, FastifyBaseLogger>().log[logLevel as LogLevel]
  )
  expectType<void>(
    fastify<Server, IncomingMessage, ServerResponse, FastifyBaseLogger>().log[logLevel as LogLevel]('')
  )
  expectType<void>(
    fastify<Server, IncomingMessage, ServerResponse, FastifyBaseLogger>().log[logLevel as LogLevel]({})
  )
  expectType<void>(
    fastify<Server, IncomingMessage, ServerResponse, FastifyBaseLogger>().log[logLevel as LogLevel]({ foo: 'bar' })
  )
  expectType<void>(
    fastify<Server, IncomingMessage, ServerResponse, FastifyBaseLogger>().log[logLevel as LogLevel](new Error())
  )
  expectType<void>(
    fastify<Server, IncomingMessage, ServerResponse, FastifyBaseLogger>().log[logLevel as LogLevel](new Foo())
  )
})

interface CustomLogger extends FastifyBaseLogger {
  customMethod(msg: string, ...args: unknown[]): void;
}

class CustomLoggerImpl implements CustomLogger {
  level = 'info'
  customMethod (msg: string, ...args: unknown[]) { console.log(msg, args) }

  // Implementation signature must be compatible with all overloads of FastifyLogFn
  info (arg1: unknown, arg2?: unknown, ...args: unknown[]): void {
    console.log(arg1, arg2, ...args)
  }

  warn (...args: unknown[]) { console.log(args) }
  error (...args: unknown[]) { console.log(args) }
  fatal (...args: unknown[]) { console.log(args) }
  trace (...args: unknown[]) { console.log(args) }
  debug (...args: unknown[]) { console.log(args) }
  silent (...args: unknown[]) { }

  child (bindings: P.Bindings, options?: P.ChildLoggerOptions): CustomLoggerImpl { return new CustomLoggerImpl() }
}
// ... (218 more lines)

Domain

Subdomains

Types

Dependencies

Frequently Asked Questions

What does logger.test-d.ts do?
logger.test-d.ts is a source file in the fastify codebase, written in typescript. It belongs to the CoreKernel domain, LifecycleManager subdomain.
What does logger.test-d.ts depend on?
logger.test-d.ts imports 6 module(s): ./logger, fastify.js, node:fs, node:http, pino, tsd.
Where is logger.test-d.ts in the architecture?
logger.test-d.ts is located at test/types/logger.test-d.ts (domain: CoreKernel, subdomain: LifecycleManager, directory: test/types).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free