...

/

Solution: Normalize Logger Interfaces

Solution: Normalize Logger Interfaces

Wrap inconsistent logger APIs behind a single, consistent .info() and .error() interface.

We'll cover the following...

Solution explanation

  • Lines 2–9: We define customLogger to simulate a non-standard logging module.

    • It exposes logInfo() and logError() instead of console.log and console.error.

    • This mismatch represents the incompatible interfaces the adapter must unify.

  • Lines 12–14: The constructor of LoggerAdapter accepts a logger instance.

    • The adapter holds a reference to whichever logger it wraps.

    • This allows client code to use a consistent interface regardless of the underlying ...