Search⌘ K
AI Features

Exercise: Logging with Template

Explore how to implement a logging system in Node.js using the Template design pattern. Learn to build ConsoleLogger and FileLogger classes that inherit and customize logging behavior. Understand the differences between Template and Strategy patterns while practicing coding solutions for effective and reusable logging.

Problem statement

Implement the same logging component we defined in the previous exercise, but this time using the Template pattern. We’d then obtain a ConsoleLogger class to log to the console or FileLogger class to log to a file. Appreciate the differences between the Template and the Strategy approaches.

Coding challenge

Write your solution code in the ...