Solution: Normalize Logger Interfaces
Wrap inconsistent logger APIs behind a single, consistent .info() and .error() interface.
We'll cover the following...
We'll cover the following...
Solution explanation
Lines 2–9: We define
customLoggerto simulate a non-standard logging module.It exposes
logInfo()andlogError()instead ofconsole.logandconsole.error.This mismatch represents the incompatible interfaces the adapter must unify.
Lines 12–14: The constructor of
LoggerAdapteraccepts aloggerinstance.The adapter holds a reference to whichever logger it wraps.
This allows client code to use a consistent interface regardless of the underlying ...