LOGS, 'file' => null, 'types' => null, ), $this->_config); $config = $this->config($config); $this->_path = $config['path']; $this->_file = $config['file']; if (!empty($this->_file) && !preg_match('/\.log$/', $this->_file)) { $this->_file .= '.log'; } } /** * Implements writing to log files. * * @param string $type The type of log you are making. * @param string $message The message you want to log. * @return boolean success of write. */ public function write($type, $message) { $debugTypes = array('notice', 'info', 'debug'); if (!empty($this->_file)) { $filename = $this->_path . $this->_file; } elseif ($type == 'error' || $type == 'warning') { $filename = $this->_path . 'error.log'; } elseif (in_array($type, $debugTypes)) { $filename = $this->_path . 'debug.log'; } else { $filename = $this->_path . $type . '.log'; } $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n"; return file_put_contents($filename, $output, FILE_APPEND); } }