function actionDefault() { echo 'Log level: '; switch (YDConfig::get('YD_LOG_LEVEL')) { case YD_LOG_DEBUG: echo 'YD_LOG_DEBUG'; break; case YD_LOG_INFO: echo 'YD_LOG_INFO'; break; case YD_LOG_WARNING: echo 'YD_LOG_WARNING'; break; default: echo 'YD_LOG_ERROR'; break; } echo '<br/><br/>'; echo 'Clearing the logfile<br/>'; YDLog::clear(); echo 'Adding debug message<br/>'; YDLog::debug('debug message'); echo 'Adding info message<br/>'; YDLog::info('info message'); echo 'Adding warning message<br/>'; YDLog::warning('warning message'); echo 'Adding error message<br/>'; YDLog::error('error message'); echo 'Testing PlainFunction<br/>'; PlainFunction(); echo 'Adding very long info message<br/>'; YDLog::info('this is a very long info message and should break up over several lines in the logfile. Each line should be a separate info message in the logfile if everything goes correctly.'); echo '<br/><a href="' . YD_SELF_SCRIPT . '?do=showlog">show logfile</a>'; }
/** * This function deletes a file or an array of files from the * target directory. * * @param $files The file name or an array of filenames * relative to the target directory. * * @returns An array with the results. */ function deleteFile($files) { if (!is_array($files)) { $files = array($files); } $res = array(); foreach ($files as $file) { // The file path $file = YDPath::join($this->_target_dir, $file); if (!is_file($file)) { $res[] = array('success' => false, 'action' => 'delete', 'type' => 'file', 'item' => $file, 'reason' => 'exist'); if ($this->_log) { YDLog::warning('Deleting file: ' . $file . ' - already exist'); } continue; } // Target directory path $dir = YDPath::getDirectoryName($file); // The directory $d = new YDFSDirectory($dir); // Delete the file if (!($success = $d->deleteFile($file))) { if ($this->_log) { YDLog::error('Deleting file: ' . $file); } } else { if ($this->_log) { YDLog::info('Deleting file: ' . $file); } } $res[] = array('success' => $success, 'action' => 'delete', 'type' => 'file', 'item' => $file, 'reason' => 'failure'); } return $res; }