...

/

Solution: Add Feature-Flagged Logger Instantiation

Solution: Add Feature-Flagged Logger Instantiation

Use a flag-to-class map in the factory to instantiate the correct logger without conditionals.

We'll cover the following...

Solution explanation

  • Lines 1–11: We define two interchangeable logger classes: FileLogger and RemoteLogger.

    • Both implement a .log() method, ensuring consistent behavior for consumers regardless of which one is used.

    • FileLogger simulates local file logging, while RemoteLogger represents a new network-based logging service.

  • ...