class Logger { private $logPath; private $debugLevel; private $service; private $levels = ['DEBUG' => 0, 'INFO' => 1, 'WARN' => 2, 'ERROR' => 3]; public function __construct($logPath = './app/logs', $debugLevel = 'DEBUG') { $this->logPath = rtrim($logPath, '/'); $this->debugLevel = strtoupper($debugLevel); $this->service = 'master'; // Default to 'master' service } // Set the service name for logging public function useService($serviceName) { $this->service = preg_replace('/[^a-z0-9_-]/i', '', strtolower($serviceName)); return $this; } public function setDebugMode($level) { $this->debugLevel = strtoupper($level); } private function shouldLog($level) { return $this->levels[$level] >= $this->levels[$this->debugLevel]; } private function getLogPath() { $date = date('Y-m-d'); $dir = "{$this->logPath}/{$this->service}"; if (!is_dir($dir)) { mkdir($dir, 0755, true); // Create service directory if not exists } return "{$dir}/{$this->service}-{$date}.log"; } public function log($level, $message) { $level = strtoupper($level); if (!isset($this->levels[$level])) $level = 'INFO'; // Default to INFO level if (!$this->shouldLog($level)) return; $time = date('H:i:s'); $entry = "[$time] [$level] [$this->service] $message" . PHP_EOL; file_put_contents($this->getLogPath(), $entry, FILE_APPEND); } public function debug($msg) { $this->log('DEBUG', $msg); } public function info($msg) { $this->log('INFO', $msg); } public function warn($msg) { $this->log('WARN', $msg); } public function error($msg) { $this->log('ERROR', $msg); } public function clearLogs() { foreach (glob("$this->logPath/*.log") as $file) { unlink($file); } } }
Warning: Undefined variable $config in /home/u615463104/domains/brooklynbassmint.com/public_html/app/config/bootstrap.php on line 21

Warning: Trying to access array offset on value of type null in /home/u615463104/domains/brooklynbassmint.com/public_html/app/config/bootstrap.php on line 21

Warning: Undefined variable $logger in /home/u615463104/domains/brooklynbassmint.com/public_html/index.php on line 4

Fatal error: Uncaught Error: Call to a member function useService() on null in /home/u615463104/domains/brooklynbassmint.com/public_html/index.php:4 Stack trace: #0 {main} thrown in /home/u615463104/domains/brooklynbassmint.com/public_html/index.php on line 4