function doLog($message, $type = 'INFO', $file = 'logfile.txt') { $date = date('Y-m-d H:i:s'); $log = $date . " [" . $type . "] " . $message . PHP_EOL; error_log($log, 3, $file); } // Example Usage doLog("User login failed for user " . $username, 'ERROR');In the example above, we define a `doLog` function that takes three arguments: the `message`, `type`, and `file`. We also provide default values for the `type` and `file` arguments if they are not provided. The function then formats the log to include the current date and time, log type, and provided message. It writes this information to the file specified by `file` using the `error_log` function. Overall, `doLog` is a useful function for logging events and errors in PHP applications. It's available in various package libraries such as `Monolog`, `Log4php`, and `KLogger`.