public function add($level, $msg) { //as a logger, i won't throw any exception to interrupt your program if (!isset($this->_conf[$level])) { if (auto::isDebugMode() || auto::isDevMode()) { auto::dqueue('<font color=red>warning</font>', 'log got no conf for level:' . $level); } else { return false; } } $rotation = $this->_getRotationByLevel($level); if (!$rotation) { $rotation = 'default'; } $dir = $this->_conf[$level]['path']; if (!is_dir($dir)) { $mk = @mkdir($dir, 777, true); if (!$mk) { auto::isDebugMode() && auto::dqueue('<font color=red>warning</font>', 'failed for make log dir:' . $dir); return false; } } $logFile = $dir . DS . $rotation . '.log'; if (!is_scalar($msg)) { $msg = var_export($msg, true); } $msg = date('Y-m-d H:i:s') . "\t" . $level . "\t" . $msg . "\n"; file_put_contents($logFile, $msg, FILE_APPEND); }