本文整理汇总了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();
}