本文整理匯總了PHP中Logs::setDb方法的典型用法代碼示例。如果您正苦於以下問題:PHP Logs::setDb方法的具體用法?PHP Logs::setDb怎麽用?PHP Logs::setDb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Logs
的用法示例。
在下文中一共展示了Logs::setDb方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: array
namespace PopTest\Log;
use Pop\Loader\Autoloader;
use Pop\Log\Logger;
use Pop\Log\Writer\Db;
use Pop\Log\Writer\File;
use Pop\Log\Writer\Mail;
use Pop\Db\Record;
// Require the library's autoloader.
require_once __DIR__ . '/../../../src/Pop/Loader/Autoloader.php';
// Call the autoloader's bootstrap function.
Autoloader::factory()->splAutoloadRegister();
class Logs extends Record
{
}
Logs::setDb(\Pop\Db\Db::factory('Sqlite', array('database' => __DIR__ . '/../tmp/test.sqlite')));
class LogTest extends \PHPUnit_Framework_TestCase
{
public function testLogConstructor()
{
$l = new Logger(new File(__DIR__ . '/../tmp/app.log'));
$l->addWriter(new File(__DIR__ . '/../tmp/app.csv'));
$this->assertInstanceOf('Pop\\Log\\Logger', $l);
$this->assertEquals(2, count($l->getWriters()));
}
public function testSetAndGetTimestamp()
{
$l = new Logger();
$l->setTimestamp('Y-m-d');
$this->assertEquals('Y-m-d', $l->getTimestamp());
}
示例2: array
<?php
require_once '../../bootstrap.php';
use Pop\Db\Db;
use Pop\Db\Record;
use Pop\Log;
use Pop\Log\Writer;
class Logs extends Record
{
}
Logs::setDb(Db::factory('Sqlite', array('database' => '../tmp/log.sqlite')));
try {
$logger = new Log\Logger(new Writer\Db(new Logs()));
$logger->addWriter(new Writer\File('../tmp/app.log'));
$logger->emerg('Yo stuff is whack man!')->info("Here's some, yo, you know, info stuff");
echo 'Done.';
} catch (\Exception $e) {
echo $e->getMessage();
}