Example #1
0
/**
 * @author neeke@php.net
 * Date: 16/1/11 上午10:15
 */
function testAction()
{
    $path = "/usr/local/nginx/html/logs";
    \SeasLog::setBasePath($path);
    \SeasLog::setBasePath($path);
    \SeasLog::notice("a");
    return;
}
Example #2
0
 public static function instance()
 {
     if (is_null(self::$self)) {
         self::$self = new self();
     }
     SeasLog::setLogger(__CLASS__);
     return self::$self;
 }
Example #3
0
 public static function emergency($message, array $content = array(), $module = '')
 {
     self::setLogPath();
     if ($module != '') {
         \SeasLog::emergency($message, $content, $module);
     } else {
         \SeasLog::emergency($message, $content);
     }
 }
Example #4
0
 public static function run()
 {
     config::getConfig();
     \SeasLog::setBasePath(config::getAnalyzerPath());
     if ($forkCount = config::getForkCount()) {
         coreRun\pcntl::setForkCount($forkCount);
         coreRun\pcntl::run();
     } else {
         coreRun\single::run();
     }
 }
Example #5
0
function test_log()
{
    $iCount = 10000;
    while ($iCount-- > 0) {
        SeasLog::error(format(array('msg' => "HelloWorld", 'id' => $iCount), "__main__", '123'), array(), 'test1');
    }
    $iCount = 10000;
    while ($iCount-- > 0) {
        SeasLog::info(format(array('msg' => "HelloWorld", 'id' => $iCount), "__main__", '123'), array(), 'test2');
    }
    $iCount = 10000;
    while ($iCount-- > 0) {
        SeasLog::debug(format(array('msg' => "HelloWorld", 'id' => $iCount), "__main__", '123'));
    }
}
Example #6
0
 public static function analyzerRun($configKey = NULL, $config = array())
 {
     if (empty($configKey) || !is_array($config) || count($config) < 1) {
         throw new \Exception('$configKey can`t be empty || $config must be an array.');
     }
     \SeasLog::setLogger($config['module']);
     $logLevel = intval($config['level']);
     if (empty($logLevel)) {
         $logLevel = SEASLOG_ERROR;
     }
     $_analyzer_count = \SeasLog::analyzerCount($logLevel);
     $_count_bar = array_key_exists('bar', $config) ? intval($config['bar']) : 1;
     if ($_analyzer_count > 0 && $_analyzer_count >= $_count_bar) {
         $to = array_key_exists('mail_to', $config) ? explode(',', $config['mail_to']) : array();
         $cc = array_key_exists('mail_cc', $config) ? explode(',', $config['mail_cc']) : array();
         $bcc = array_key_exists('mail_bcc', $config) ? explode(',', $config['mail_bcc']) : array();
         $subject = ' report - ' . $configKey . ' - ' . date('Y-m-d H:i:s', time());
         $_title = $config['module'] . ' 检测到 ' . $_analyzer_count . "个问题\n\n";
         $_detail = \SeasLog::analyzerDetail($logLevel);
         $_detail = '以下是此次检测详情<br /><br />' . implode("<br />", $_detail);
         $content = mailTpl::processMail($_title, $_detail, 'processed time ' . date('Y-m-d H:i:s', time()));
         alarmer::instanse()->SendEmail($subject, $content, $to, $cc, $bcc);
     }
 }
Example #7
0
<?php

/**
 * @author neeke@php.net
 */
ini_set('seaslog.disting_type', 1);
$countResult = SeasLog::analyzerCount();
ini_set('seaslog.disting_type', 1);
SeasLog::setBasePath(realpath('.'));
SeasLog::setLogger('log');
SeasLog::info('log info test');
print_r($countResult);
Example #8
0
<?php

/**
 * @author neeke@php.net
 * Date: 16/5/12 下午4:21
 */
$array = ['key' => 'test array'];
SeasLog::debug('SeasLog Test: {var}', ['{var}' => $array['key']]);
Example #9
0
    /**
     * 返回错误
     *
     * @param string $msg
     * @param string $sql
     */
    public function halt($msg = '', $sql = '')
    {
        $error_info = $this->_sth->errorInfo();
        $s = '<html>
					<head>
					<title>ERROR</title>
					<style type="text/css">
					body {background-color:	#fff;margin:40px;font-family:	Lucida Grande, Verdana, Sans-serif;font-size:12px;color:#000;}
					#content  {border:	#999 1px solid;background-color:	#fff;padding:	20px 20px 12px 20px;}
					h1 {font-weight:normal;font-size:14px;color:#990000;margin:0 0 4px 0;}
					</style>
					</head>
					<body>
						<div id="content">
							<h1>' . $error_info[2] . '</h1>
							' . $error_info[1] . '<br>
							' . $this->_sql . '
						</div>
					</body>
				</html>';
        SeasLog::critical(json_encode($error_info));
        exit($s);
    }
Example #10
0
<?php

/**
 * @author neeke@php.net
 * Date: 15-11-9 下午7:16
 */
for ($i = 0; $i < 100; $i++) {
    SeasLog::error(time());
    sleep(1);
    var_dump(SeasLog::getBuffer());
}
Example #11
0
 public function setLogger($module)
 {
     \SeasLog::setLogger($module);
 }
Example #12
0
 public static function errorCallBack($type, $error, $callinfo)
 {
     SeasLog::error(json_encode(array($type, $error, $callinfo)));
 }
Example #13
0
<?php

/**
 * @author ciogao@gmail.com
 * Date: 14-1-27 下午4:41
 */
SeasLog::getBasePath();
SeasLog::setBasePath('/log/test/base/path');
SeasLog::setLogger('test/logger');
SeasLog::log(SEASLOG_ERROR, 'this is a error test by ::log');
SeasLog::debug('this is a {userName} debug', array('{userName}' => 'neeke'));
SeasLog::info('this is a info log');
SeasLog::notice('this is a notice log');
SeasLog::warning('your {website} was down,please {action} it ASAP!', array('{website}' => 'github.com', '{action}' => 'rboot'));
SeasLog::error('a error log');
SeasLog::critical('some thing was critical');
SeasLog::alert('yes this is a {messageName}', array('{messageName}' => 'alertMSG'));
SeasLog::emergency('Just now, the house next door was completely burnt out! {note}', array('{note}' => 'it`s a joke'));
var_dump(SeasLog::analyzerCount());
var_dump(SeasLog::analyzerDetail(SEASLOG_INFO, date('Ymd', time())));
var_dump(SeasLog::analyzerDetail(SEASLOG_DEBUG, date('Ymd', time()), 'neeke', 1, 40));
var_dump(SeasLog::getLastLogger());
$buffer = SeasLog::getBuffer();
var_dump($buffer);
Example #14
0
<?php

/**
 * @author ciogao@gmail.com
 * Date: 15-10-17 下午4:12
 */
var_dump(SEASLOG_DETAIL_ORDER_ASC);
var_dump(SEASLOG_DETAIL_ORDER_DESC);
var_dump(SeasLog::getBasePath());
var_dump(SeasLog::getLastLogger());
SeasLog::debug('debug test');
SeasLog::error('错误{aaa}', array('{aaa}' => 'bbb'));
SeasLog::error('错误{aaa}', array('{aaa}' => 'ccc'), 'cc');
SeasLog::log('error', '错误{aaa}', array('{aaa}' => 'ddd'));
SeasLog::log('asdf', '错误{aaa}', array());
//Seaslog::debug("test");
var_dump(SeasLog::analyzerCount());
var_dump(Seaslog::analyzerDetail("all", "*", NULL, 1, 10, SEASLOG_DETAIL_ORDER_DESC));
var_dump(SeasLog::analyzerCount(SEASLOG_ALL));
var_dump(Seaslog::analyzerDetail(SEASLOG_ERROR, "*", NULL, 1, 1000, SEASLOG_DETAIL_ORDER_DESC));
var_dump(SeasLog::analyzerCount(SEASLOG_DEBUG));
var_dump(Seaslog::analyzerDetail(SEASLOG_DEBUG));
Example #15
0
<?php

/**
 * @Author: leandre
 * @Date:   2015-10-15 11:08:43
 * @Last Modified by:   leandre
 * @Last Modified time: 2015-10-15 11:15:24
 */
SeasLog::setBasePath('./logs/');
SeasLog::setLogger('test');
SeasLog::info('this is a info log');
SeasLog::notice('this is a notice log');
SeasLog::flushBuffer();
sleep(60);
SeasLog::error('a error log');
SeasLog::critical('some thing was critical');
Example #16
0
<?php

/**
 * @version 0.0.0.1
 */
SeasLog::setBasePath('./log');
SeasLog::setLogger('test');
SeasLog::log(SEASLOG_INFO, 'this is the seaslog test2 !');
Example #17
0
<?php

// $basepath1 = SeasLog::getBasePath();
// SeasLog::setBasePath('/Log/base_test');
// $basepath2 = SeasLog::getBasePath();
// var_dump($basepath1,$basepath2);
// echo '<br/>';
// $lastLogger_1 = SeasLog::getLastLogger();
// var_dump($lastLogger_1);
SeasLog::log(SEASLOG_ERROR, 'this is a error test by ::log');
SeasLog::info('this is a info log');
//SeasLog::warning('your {website} was down,please {action} it ASAP!',array('{website}' => 'github.com','{action}' => 'rboot'));
SeasLog::error('a error log');
echo '<br/>';
$countResult_1 = SeasLog::analyzerCount();
$countResult_2 = SeasLog::analyzerCount(SEASLOG_WARNING);
$countResult_3 = SeasLog::analyzerCount(SEASLOG_ERROR, date('Ymd', time()));
//,$countResult_2,$countResult_3
print_r($countResult_1);
echo '<br/>';
print_r($countResult_2);
echo '<br/>';
print_r($countResult_3);
Example #18
0
 private function testLogger()
 {
     SeasLog::setLogger('aaa');
     SeasLog::setLogger('bbb');
 }
Example #19
0
<?php

/**
 * @author ciogao@gmail.com
 * Date: 14-3-8 下午4:30
 */
function seaslog_autoloader($class)
{
    if (!class_exists($class)) {
        $filename = BASE_PATH . '/' . str_replace('\\', '/', $class) . '.php';
        include_once "{$filename}";
    }
}
spl_autoload_register('seaslog_autoloader');
\SeasLog::setBasePath(BASE_PATH . '/result');