Skip to content

Instantly share code, notes, and snippets.

@rongself
Created February 26, 2015 03:11
Show Gist options
  • Save rongself/80374e87e91171fefe47 to your computer and use it in GitHub Desktop.
Save rongself/80374e87e91171fefe47 to your computer and use it in GitHub Desktop.
easy file log
<?php
/**
* Created by PhpStorm.
* User: Ron
* Date: 14-12-30
* Time: 下午5:57
*/
class Application_Model_SystemLog extends Zend_Log {
public function __construct($fileName,$subDirName='')
{
$logDir = APPLICATION_PATH.'/../log/';
$dir = $logDir.$subDirName.DIRECTORY_SEPARATOR;
if(!file_exists($logDir.$subDirName.DIRECTORY_SEPARATOR)){
if(!@mkdir($logDir.$subDirName.DIRECTORY_SEPARATOR)){
throw new Zend_Exception('Cannot create directory with path:'.$dir);
}
}
$writer = new Zend_Log_Writer_Stream($dir.date('Ymd').'-'.$fileName);
parent::__construct($writer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment