示例#1
0
文件: Console.php 项目: rezon/sugi
 protected function __construct($config = array())
 {
     // override default format if no formating is given
     $this->_format = '<script>window.console && console.log("[{level}] {message}");</script>';
     // create it
     parent::__construct($config);
 }
示例#2
0
文件: Stdout.php 项目: rezon/sugi
 protected function __construct($config = array())
 {
     // override default format if no formating is given
     $this->_format = '<div class="{level}">[{level}] {message}</div>';
     // create it
     parent::__construct($config);
 }
示例#3
0
文件: File.php 项目: rezon/sugi
 /**
  * Class constructor
  * 
  * @param array $config - the key 'filename' is a must
  */
 public function __construct($config = array())
 {
     // overriding default format
     $this->_format = '[{Y}-{m}-{d} {H}:{i}:{s}] [{ip}] [{level}] {message}';
     // create it
     parent::__construct($config);
     // custom settings
     if (isset($config['filename'])) {
         $this->_filename = $config['filename'];
     } else {
         throw new \Exception("filename parameter is not provided in the config");
     }
     if (isset($config['filemode'])) {
         $this->_filemode = $config['filemode'];
     }
 }
示例#4
0
文件: Loggly.php 项目: rezon/sugi
 /**
  * Class constructor
  */
 public function __construct($config)
 {
     // overriding default format
     $this->_format = "{'level': '{level}', 'message': '{message}', 'time': '{Y}-{m}-{d} {H}:{i}:{s}', 'ip': '{ip}'}";
     // create it
     parent::__construct($config);
     // custom config
     if (isset($config['url'])) {
         $this->_url = $config['url'];
     } else {
         throw new \Exception('url parameter is not provided in the config');
     }
     if (isset($config['json'])) {
         $this->_json = $config['json'];
     }
 }
示例#5
0
文件: logger.php 项目: rezon/sugi
 */
include "common.php";
use Sugi\Logger;
?>
<!doctype html>
<html lang="en">
<head>
	<title>Sugi Tests</title>
	<meta charset="utf-8" />
</head>
<body>
	<a href="index.php">back</a><br />

<?php 
Logger::stdout();
Logger::stdout(array('format' => '[{level}] [{Y}.{m}.{d} {H}:{i}:{s}] {message}<br />'));
$c = Logger::console();
Logger::loggly(array('filter' => 'all -debug', 'url' => 'localhost'));
$f = Logger::file(array('filename' => 'log/test.log', 'filter' => 'none +notice'));
Logger::log('some "debug" information', 'debug');
$c->message('this message have to be sholn only in console', 'notice');
Logger::log("somethin'\nwent WRONG!", 'notice');
$f->message('this is only for file, but it shall not be written', 'info');
?>

	<br />
	<a href="index.php">back</a>
	<br />
</body>
</html>
示例#6
0
文件: Cron.php 项目: rezon/sugi
 public static function error_handler($errno, $errstr, $errfile, $errline)
 {
     $errortype = array(E_ERROR => "Error", E_WARNING => "Warning", E_PARSE => "Parse Error", E_NOTICE => "Notice", E_CORE_ERROR => "Core Error", E_CORE_WARNING => "Core Warning", E_COMPILE_ERROR => "Compile Error", E_COMPILE_WARNING => "Compile Warning", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice", E_STRICT => "Runtime Notice", E_RECOVERABLE_ERROR => "Catchable fatal error", E_DEPRECATED => "Deprecated Notice", E_USER_DEPRECATED => "User Dreprecated Notice");
     $current_job = static::$current_job;
     Logger::log("Cron job {$current_job} {$errortype[$errno]}: {$errstr} in {$errfile} line {$errline}", 'error');
     // Don't execute PHP internal error handler
     return true;
 }