The AppLogger class provides a singleton logger instance for the application using Fastify. This class cannot be instantiated directly.

Constructors

Methods

Constructors

  • Private constructor to prevent instantiation.

    Returns default

    Throws an error if an attempt is made to create an instance of this class.

Methods

  • Returns a singleton Fastify logger instance configured with the specified service name. If the logger instance does not already exist, it is created and configured.

    Parameters

    • SERVICE_NAME: string

      The name of the service for which the logger is being created.

    Returns FastifyInstance<
        RawServerDefault,
        IncomingMessage,
        ServerResponse<IncomingMessage>,
        FastifyBaseLogger,
        FastifyTypeProviderDefault,
    >

    The Fastify logger instance.


    const logger = AppLogger.getLogger('MyService');
    logger.info('This is an info message');
    logger.error('This is an error message');