Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Logging capabilities

  • Loading branch information...
commit 660d3d14de612a18d2e4bfc14708c72c93baa7fa 1 parent c409970
@greut authored
View
3  config/bootstrap.php
@@ -1,7 +1,6 @@
<?php
-use \lithium\core\Libraries;
-
+use lithium\core\Libraries;
use ActiveRecord\Config;
if (!defined('ACTIVERECORD_LIB_PATH')) {
View
20 extensions/analysis/Log.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace li3_activerecord\extensions\analysis;
+
+class Log extends \lithium\core\Object
+{
+ protected $_classes = array(
+ 'logger' => 'lithium\\analysis\\Logger'
+ );
+
+ public function log()
+ {
+ $this->__call('info', func_get_args());
+ }
+
+ public function __call($method, $args)
+ {
+ return call_user_func_array(array($this->_classes['logger'], $method), $args);
+ }
+}
View
8 extensions/data/source/ActiveRecord.php
@@ -4,6 +4,7 @@
use ActiveRecord\Config;
use lithium\util\String;
+use li3_activerecord\extensions\analysis\Log;
class ActiveRecord extends \lithium\data\source\Database {
@@ -17,7 +18,8 @@ public function __construct(array $config=array()) {
'password' => '',
'database' => 'li3',
'cache' => false,
- 'cache_expire' => 30
+ 'cache_expire' => 30,
+ 'logging' => false,
), $config);
$cfg->set_model_directory($config['model_directory']);
$driver = $config['driver'] = strtolower($config['driver']);
@@ -33,6 +35,10 @@ public function __construct(array $config=array()) {
);
$cfg->set_cache($config['cache'], $options);
}
+ if ($config['logging']) {
+ $cfg->set_logging($config['logging']);
+ $cfg->set_logger(new Log());
+ }
$cfg->set_connections(array('default' => $connection));
$cfg->set_default_connection('default');
parent::__construct($config);
Please sign in to comment.
Something went wrong with that request. Please try again.