CoolFace
Apppublic

strong-tie/inbound-calls

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
logger.d.ts106 linesDownload Raw Back to types
1import { FastifyError } from '@fastify/error'2import { FastifyInstance } from './instance'3import { FastifyReply } from './reply'4import { FastifyRequest } from './request'5import { RouteGenericInterface } from './route'6import { FastifySchema } from './schema'7import { FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider'8import { ContextConfigDefault, RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerBase, RawServerDefault } from './utils'9 10import pino from 'pino'11 12/**13 * Standard Fastify logging function14 */15export type FastifyLogFn = pino.LogFn16 17export type LogLevel = pino.LevelWithSilent18 19export type Bindings = pino.Bindings20 21export type ChildLoggerOptions = pino.ChildLoggerOptions22 23export interface FastifyBaseLogger extends pino.BaseLogger {24  child(bindings: Bindings, options?: ChildLoggerOptions): FastifyBaseLogger25}26 27// TODO delete FastifyBaseLogger in the next major release. It seems that it is enough to have only FastifyBaseLogger.28/**29 * @deprecated Use FastifyBaseLogger instead30 */31export type FastifyLoggerInstance = FastifyBaseLogger32 33export interface FastifyLoggerStreamDestination {34  write(msg: string): void;35}36 37export type PinoLoggerOptions = pino.LoggerOptions38 39// TODO: once node 18 is EOL, this type can be replaced with plain FastifyReply.40/**41 * Specialized reply type used for the `res` log serializer, since only `statusCode` is passed in certain cases.42 */43export type ResSerializerReply<44  RawServer extends RawServerBase,45  RawReply extends FastifyReply<RouteGenericInterface, RawServer>46> = Partial<RawReply> & Pick<RawReply, 'statusCode'>47 48/**49 * Fastify Custom Logger options.50 */51export interface FastifyLoggerOptions<52  RawServer extends RawServerBase = RawServerDefault,53  RawRequest extends FastifyRequest<RouteGenericInterface, RawServer, RawRequestDefaultExpression<RawServer>, FastifySchema, FastifyTypeProvider> = FastifyRequest<RouteGenericInterface, RawServer, RawRequestDefaultExpression<RawServer>, FastifySchema, FastifyTypeProviderDefault>,54  RawReply extends FastifyReply<RouteGenericInterface, RawServer, RawRequestDefaultExpression<RawServer>, RawReplyDefaultExpression<RawServer>, ContextConfigDefault, FastifySchema, FastifyTypeProvider> = FastifyReply<RouteGenericInterface, RawServer, RawRequestDefaultExpression<RawServer>, RawReplyDefaultExpression<RawServer>, ContextConfigDefault, FastifySchema, FastifyTypeProviderDefault>55> {56  serializers?: {57    req?: (req: RawRequest) => {58      method?: string;59      url?: string;60      version?: string;61      host?: string;62      remoteAddress?: string;63      remotePort?: number;64      [key: string]: unknown;65    };66    err?: (err: FastifyError) => {67      type: string;68      message: string;69      stack: string;70      [key: string]: unknown;71    };72    res?: (res: ResSerializerReply<RawServer, RawReply>) => {73      statusCode?: string | number;74      [key: string]: unknown;75    };76  };77  level?: string;78  file?: string;79  genReqId?: (req: RawRequest) => string;80  stream?: FastifyLoggerStreamDestination;81}82 83export interface FastifyChildLoggerFactory<84  RawServer extends RawServerBase = RawServerDefault,85  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,86  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,87  Logger extends FastifyBaseLogger = FastifyBaseLogger,88  TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault89> {90  /**91   * @param logger The parent logger92   * @param bindings The bindings object that will be passed to the child logger93   * @param childLoggerOpts The logger options that will be passed to the child logger94   * @param rawReq The raw request95   * @this The fastify instance96   * @returns The child logger instance97   */98  (99    this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,100    logger: Logger,101    bindings: Bindings,102    childLoggerOpts: ChildLoggerOptions,103    rawReq: RawRequest104  ): Logger105}106