好久没写php了,突然做个实验,发现竟然没有日志,哎
1 | <?phpdefined( 'API' ) or exit ( 'Access Denied' ); class Log{ private $FilePath ; private $FileName ; private $m_MaxLogFileNum ; private $m_RotaType ; private $m_RotaParam ; private $m_InitOk ; private $m_Priority ; private $m_LogCount ; const EMERG = 0; const FATAL = 0; const ALERT = 100; const CRIT = 200; const ERROR = 300; const WARN = 400; const NOTICE = 500; const INFO = 600; const DEBUG = 700; const LOG_SUFFIXED = ".log.txt" ; const DEFAULT_ROTE = 5242880; public function __construct( $dir , $filename , $priority = Log::INFO, $maxlogfilenum = 3, $rotatype = 1, $rotaparam = LOG::DEFAULT_ROTE) { $dot_offset = strpos ( $filename , "." ); if ( $dot_offset !== false) $this ->FileName = substr ( $filename ,0, $dot_offset ); else $this ->FileName = $filename ; $this ->FilePath = $dir ; $this ->m_MaxLogFileNum = intval ( $maxlogfilenum ); $this ->m_RotaParam = intval ( $rotaparam ); $this ->m_RotaType = intval ( $rotatype ); $this ->m_Priority = intval ( $priority ); $this ->m_LogCount = 0; $this ->m_InitOk = $this ->InitDir(); umask(0000); $path = $this ->createPath( $this ->FilePath, $this ->FileName); if (! $this ->isExist( $path )) { if (! $this ->createDir( $this ->FilePath)) { # echo ( "创建目录失败!" ); } if (! $this ->createLogFile( $path )){ # echo ( "创建文件失败!" ); } } } private function createPath( $dir , $file ) { $file = fopen ( $dir .DIRECTORY_SEPARATOR. $file , 'w' ); if ( $file ) { fclose( $file ); } return $dir .DIRECTORY_SEPARATOR. $file ; } private function InitDir() { if ( is_dir ( $this ->FilePath) === false) { if (! $this ->createDir( $this ->FilePath)) {
|
Copy after login