| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 | <?phpnamespace Spider\Lib;use Dever;class Log{	private $time = 0;	private $file;	private $content = array();	public function __construct($key)	{		$key = date('Y-m-d') . '_' . $key;		$this->file = Dever::path(Dever::data() . 'logs/', 'spider/' . $key);	}	public function get()	{		$content = file_get_contents($this->file);		return $content;	}	public function add($string)	{		$time = Dever::msectime();		if ($this->time == 0) {			$hs = 0;			$this->time = $time;		} else {			$hs = $time - $this->time;		}		$time = date('Y-m-d H:i:s');		$content = array		(			'时间:' . $time,			'耗时:' . $hs . 'MS',			'内容:' . str_replace("\n", '<--', $string),		);		$this->content[] = implode(' ', $content);	}	public function out()	{		print_r(Dever::table($this->content));	}	public function save()	{		$content = implode("\r\n", $this->content);		file_put_contents($this->file, $content, FILE_APPEND);	}}
 |