<?php function system_log($text) { $file_name = 'system_log.txt'; $file = fopen($file_name, "a"); $cur_Date = date('Y-m-d H:i:s'); $backtrack = debug_backtrace(); $function = $backtrack[count($backtrack) - 1]; $location = 'File = "' . __FILE__ . '"; Function = "' . $function['function'] . '"; Line = ' . $function['line'] . ';'; $text = $cur_Date . ' => Log = "' . $text . '"; ' . $location . ' ' . PHP_EOL; fwrite($file, $text); } function test_log($log) { system_log($log); } $array = array('key1' => 'value1', 'key2' => array('value-2-1', 'value-2-3', 'value-2-3')); test_log('Hello ');
* Date: 16/5/14 下午10:56 */ function format($mMsg, $sMethod = '', $sLine = '') { if (is_array($mMsg)) { $mMsg = var_export($mMsg, true); } $sMsg = sprintf("%s | %s | %s\n", "TestModule", $sMethod, $sLine); $sMsg .= $mMsg; $sMsg .= "\n\n"; return $sMsg; } 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')); } } while (True) { sleep(1); test_log(); }
<?php require_once './doc/examples/PHPCask.class.php'; function test_log($msg) { echo "===============\n"; echo $msg, "\n"; } test_log("connecting…"); $phpcask = new PHPCask('phpcask@localhost', $argv[1]); test_log("put…"); var_dump($phpcask->put("foo", "bar")); test_log("get…"); var_dump($phpcask->get("foo")); test_log("put…"); var_dump($phpcask->put("foo2", "bar2")); test_log("list_keys…"); var_dump($phpcask->list_keys()); test_log("delete…"); var_dump($phpcask->delete("foo")); test_log("get…"); var_dump($phpcask->get("foo")); test_log("list_keys…"); var_dump($phpcask->list_keys());