class Logger { private static $instance = null; private function __construct() {} public static function getInstance() { if (!isset(self::$instance)) { self::$instance = new Logger(); } return self::$instance; } public function log($message) { $file = 'log.txt'; $fp = fopen($file, 'a'); fwrite($fp, sprintf("%s - %s\n", date('Y-m-d H:i:s'), $message)); fclose($fp); } }This code creates a Logger class with a private constructor and a getInstance() method that returns a single instance of the class. The log() method writes a message to a log file. This design pattern is often included in many logging libraries or packages. One example is the Monolog package library, which provides a robust logging system with support for multiple handlers, processors, and formatters.