-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
180 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE TABLE `kv_log` ( | ||
`gameId` char(36) DEFAULT NULL, | ||
`groupId` char(36) NOT NULL, | ||
`userId` char(36) DEFAULT NULL, | ||
`created` datetime, | ||
`content` blob | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Kubikvest\Logger; | ||
|
||
use Monolog\Handler\AbstractProcessingHandler; | ||
use Monolog\Logger; | ||
use Packaged\QueryBuilder\Assembler\QueryAssembler; | ||
use Packaged\QueryBuilder\Builder\QueryBuilder; | ||
|
||
class MysqlHandler extends AbstractProcessingHandler | ||
{ | ||
/** | ||
* @var \PDO | ||
*/ | ||
protected $pdo; | ||
|
||
/** | ||
* @var QueryBuilder | ||
*/ | ||
protected $queryBuilder; | ||
protected $table = 'kv_log'; | ||
|
||
public function __construct(\PDO $pdo, QueryBuilder $queryBuilder, $level = Logger::DEBUG, $bubble = true) | ||
{ | ||
$this->pdo = $pdo; | ||
$this->queryBuilder = $queryBuilder; | ||
|
||
parent::__construct($level, $bubble); | ||
} | ||
protected function write(array $record) | ||
{ | ||
var_dump($record); | ||
//$query = $this->queryBuilder->insertInto($this->table); | ||
//$this->pdo->exec(QueryAssembler::stringify($query)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Kubikvest\Logger; | ||
|
||
use \Packaged\QueryBuilder\Builder\QueryBuilder; | ||
use Monolog\Logger; | ||
|
||
class MysqlHandlerTest extends \PHPUnit_Extensions_Database_TestCase | ||
{ | ||
public function getConnection() | ||
{ | ||
$dsn = 'mysql:dbname=kubikvest;host='.getenv('DB_HOST').';charset=UTF8'; | ||
$pdo = new \PDO($dsn, 'root'); | ||
|
||
return $this->createDefaultDBConnection($pdo); | ||
} | ||
|
||
public function getDataSet() | ||
{ | ||
return $this->createFlatXMLDataSet(__DIR__.'/../../fixtures/kv_log.xml'); | ||
} | ||
|
||
public function testGetInstance() | ||
{ | ||
$actual = new MysqlHandler($this->getConnection()->getConnection(), new QueryBuilder()); | ||
|
||
$this->assertInstanceOf('\\Kubikvest\\Logger\\MysqlHandler', $actual); | ||
} | ||
|
||
public function testLog() | ||
{ | ||
$handler = new MysqlHandler($this->getConnection()->getConnection(), new QueryBuilder()); | ||
$logger = new Logger('user.track'); | ||
$logger->setHandlers([$handler]); | ||
$logger->log(Logger::INFO, 'Checkpoint', [ | ||
'gameId' => 'sdf', | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" ?> | ||
<dataset> | ||
<kv_log gameId="adff5c92-008c-47ac-bad8-11be43ea1469" | ||
groupId="adff5c92-008c-47ac-bad8-11be43ea1469" | ||
userId="adff5c92-008c-47ac-bad8-11be43ea1469" | ||
created="2010-04-26 12:14:20" | ||
content="{}"/> | ||
</dataset> |