...
/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...
We'll cover the following...
Solution explanation
Lines 1–11: We define two interchangeable logger classes:
FileLoggerandRemoteLogger.Both implement a
.log()method, ensuring consistent behavior for consumers regardless of which one is used.FileLoggersimulates local file logging, whileRemoteLoggerrepresents a new network-based logging service.
...