Permalink
Browse files

Implementing database logger and addind lazy load to models

  • Loading branch information...
real34 committed Sep 3, 2010
1 parent a945c8a commit 689aa9536aaf064a1dda5c642c790a553bb48b8b
View
@@ -1,3 +1,6 @@
[submodule "plugins/debug_kit"]
path = plugins/debug_kit
url = http://github.com/cakephp/debug_kit.git
+[submodule "plugins/lazy_model"]
+ path = plugins/lazy_model
+ url = http://github.com/Phally/lazy_model.git
View
@@ -30,7 +30,8 @@
* @package cake
* @subpackage cake.app
*/
-class AppModel extends Model {
+App::import('Lib', 'LazyModel.LazyModel');
+class AppModel extends LazyModel {
public $recursive = -1;
public $actsAs = array('Containable');
View
@@ -47,4 +47,9 @@
* Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
* Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
*
- */
+ */
+
+CakeLog::config('default', array(
+ 'engine' => 'DatabaseLog',
+ 'model' => 'Log'
+ ));
@@ -23,5 +23,11 @@ class CakefestSchema extends CakeSchema {
'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)),
'tableParameters' => array('charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB')
);
+ var $logs = array(
+ 'id' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 36, 'key' => 'primary'),
+ 'type' => array('type' => 'string', 'null' => false, 'default' => NULL, 'length' => 100),
+ 'message' => array('type' => 'string', 'null' => false, 'default' => NULL),
+ 'created' => array('type' => 'datetime', 'null' => false, 'default' => NULL)
+ );
}
?>
@@ -73,6 +73,7 @@ function login() {
}
function logout() {
+ CakeLog::write('logout', sprintf('The user %s logged out', $this->Auth->user('username')));
$this->redirect($this->Auth->logout());
}
View
@@ -0,0 +1,13 @@
+<?php
+App::import('Core', 'ClassRegistry');
+class DatabaseLog {
+
+ protected $model = null;
+ public function __construct($options = array()) {
+ $this->model = ClassRegistry::init($options['model']);
+ }
+
+ public function write($type, $message) {
+ $this->model->save(compact('type', 'message'));
+ }
+}
Submodule lazy_model added at 1ab509
@@ -1,2 +1,2 @@
-1283547544
+1283550469
a:8:{s:2:"id";a:5:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:36;s:3:"key";s:7:"primary";}s:7:"user_id";a:5:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:36;s:3:"key";s:5:"index";}s:5:"title";a:4:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:200;}s:11:"description";a:4:{s:4:"type";s:4:"text";s:4:"null";b:1;s:7:"default";N;s:6:"length";N;}s:4:"date";a:5:{s:4:"type";s:4:"date";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;s:3:"key";s:5:"index";}s:4:"time";a:4:{s:4:"type";s:4:"time";s:4:"null";b:1;s:7:"default";N;s:6:"length";N;}s:7:"created";a:4:{s:4:"type";s:8:"datetime";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;}s:8:"modified";a:4:{s:4:"type";s:8:"datetime";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;}}
@@ -1,2 +1,2 @@
-1283547544
+1283550482
a:5:{s:2:"id";a:5:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:36;s:3:"key";s:7:"primary";}s:8:"username";a:4:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:20;}s:8:"password";a:4:{s:4:"type";s:6:"string";s:4:"null";b:0;s:7:"default";N;s:6:"length";i:70;}s:7:"created";a:4:{s:4:"type";s:8:"datetime";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;}s:8:"modified";a:4:{s:4:"type";s:8:"datetime";s:4:"null";b:0;s:7:"default";N;s:6:"length";N;}}
@@ -1,2 +1,2 @@
-1283546561
+1283550620
a:1:{s:11:"LC_MESSAGES";a:2:{s:0:"";a:1:{s:7:"default";a:0:{}}s:5:"en-us";a:2:{s:9:"debug_kit";a:31:{s:36:"Component initialization and startup";s:0:"";s:17:"Controller Action";s:0:"";s:24:"Render Controller Action";s:0:"";s:36:"Could not load DebugToolbar panel %s";s:0:"";s:70:"There are no active panels. You must enable a panel to see its output.";s:0:"";s:15:"Request History";s:0:"";s:28:"No previous requests logged.";s:0:"";s:27:"previous requests available";s:0:"";s:26:"Restore to current request";s:0:"";s:4:"Logs";s:0:"";s:4:"Time";s:0:"";s:7:"Message";s:0:"";s:43:"There were no log entries made this request";s:0:"";s:7:"Request";s:0:"";s:13:"Current Route";s:0:"";s:7:"Session";s:0:"";s:8:"Sql Logs";s:0:"";s:33:"toggle (%s) query explains for %s";s:0:"";s:59:"No slow queries!, or your database does not support EXPLAIN";s:0:"";s:30:"No active database connections";s:0:"";s:6:"Memory";s:0:"";s:18:"Current Memory Use";s:0:"";s:15:"Peak Memory Use";s:0:"";s:6:"Timers";s:0:"";s:7:"%s (ms)";s:0:"";s:19:"Total Request Time:";s:0:"";s:10:"Time in ms";s:0:"";s:5:"Graph";s:0:"";s:14:"View Variables";s:0:"";s:43:"Starting %sms into the request, taking %sms";s:0:"";s:9:"%plural-c";s:35:"nplurals=INTEGER;plural=EXPRESSION;";}s:7:"default";a:0:{}}}}
@@ -1,2 +1,2 @@
-1283547545
-a:13:{s:43:"/opt/local/apache2/htdocs/cakephp/cake/libs";a:25:{i:0;s:43:"/opt/local/apache2/htdocs/cakephp/cake/libs";i:1;s:49:"/opt/local/apache2/htdocs/cakephp/cake/libs/cache";i:2;s:54:"/opt/local/apache2/htdocs/cakephp/cake/libs/controller";i:3;s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/controller/components";i:4;s:47:"/opt/local/apache2/htdocs/cakephp/cake/libs/log";i:5;s:49:"/opt/local/apache2/htdocs/cakephp/cake/libs/model";i:6;s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/behaviors";i:7;s:61:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources";i:8;s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources/dbo";i:9;s:48:"/opt/local/apache2/htdocs/cakephp/cake/libs/view";i:10;s:57:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements";i:11;s:63:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email";i:12;s:68:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email/html";i:13;s:68:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email/text";i:14;s:55:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/errors";i:15;s:56:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/helpers";i:16;s:56:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts";i:17;s:62:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email";i:18;s:67:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email/html";i:19;s:67:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email/text";i:20;s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/js";i:21;s:60:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/rss";i:22;s:60:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/xml";i:23;s:54:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/pages";i:24;s:58:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/scaffolds";}s:46:"/opt/local/apache2/htdocs/cakefest/controllers";a:1:{i:0;s:46:"/opt/local/apache2/htdocs/cakefest/controllers";}s:40:"/opt/local/apache2/htdocs/cakefest/views";a:17:{i:0;s:40:"/opt/local/apache2/htdocs/cakefest/views";i:1;s:49:"/opt/local/apache2/htdocs/cakefest/views/elements";i:2;s:55:"/opt/local/apache2/htdocs/cakefest/views/elements/email";i:3;s:60:"/opt/local/apache2/htdocs/cakefest/views/elements/email/html";i:4;s:60:"/opt/local/apache2/htdocs/cakefest/views/elements/email/text";i:5;s:47:"/opt/local/apache2/htdocs/cakefest/views/events";i:6;s:52:"/opt/local/apache2/htdocs/cakefest/views/events/json";i:7;s:48:"/opt/local/apache2/htdocs/cakefest/views/layouts";i:8;s:54:"/opt/local/apache2/htdocs/cakefest/views/layouts/email";i:9;s:59:"/opt/local/apache2/htdocs/cakefest/views/layouts/email/html";i:10;s:59:"/opt/local/apache2/htdocs/cakefest/views/layouts/email/text";i:11;s:51:"/opt/local/apache2/htdocs/cakefest/views/layouts/js";i:12;s:53:"/opt/local/apache2/htdocs/cakefest/views/layouts/json";i:13;s:52:"/opt/local/apache2/htdocs/cakefest/views/layouts/rss";i:14;s:52:"/opt/local/apache2/htdocs/cakefest/views/layouts/xml";i:15;s:46:"/opt/local/apache2/htdocs/cakefest/views/pages";i:16;s:46:"/opt/local/apache2/htdocs/cakefest/views/users";}s:48:"/opt/local/apache2/htdocs/cakephp/cake/libs/view";a:16:{i:0;s:48:"/opt/local/apache2/htdocs/cakephp/cake/libs/view";i:1;s:57:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements";i:2;s:63:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email";i:3;s:68:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email/html";i:4;s:68:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email/text";i:5;s:55:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/errors";i:6;s:56:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/helpers";i:7;s:56:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts";i:8;s:62:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email";i:9;s:67:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email/html";i:10;s:67:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email/text";i:11;s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/js";i:12;s:60:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/rss";i:13;s:60:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/xml";i:14;s:54:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/pages";i:15;s:58:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/scaffolds";}s:39:"/opt/local/apache2/htdocs/cakefest/libs";a:2:{i:0;s:39:"/opt/local/apache2/htdocs/cakefest/libs";i:1;s:46:"/opt/local/apache2/htdocs/cakefest/libs/routes";}s:60:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/vendors";a:2:{i:0;s:60:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/vendors";i:1;s:67:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/vendors/shells";}s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/controller/components";a:1:{i:0;s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/controller/components";}s:75:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/controllers/components";a:1:{i:0;s:75:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/controllers/components";}s:41:"/opt/local/apache2/htdocs/cakefest/models";a:1:{i:0;s:41:"/opt/local/apache2/htdocs/cakefest/models";}s:61:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources";a:2:{i:0;s:61:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources";i:1;s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources/dbo";}s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/behaviors";a:1:{i:0;s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/behaviors";}s:58:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views";a:4:{i:0;s:58:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views";i:1;s:67:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/elements";i:2;s:66:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/helpers";i:3;s:73:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/toolbar_access";}s:66:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/helpers";a:1:{i:0;s:66:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/helpers";}}
+1283550641
+a:14:{s:39:"/opt/local/apache2/htdocs/cakefest/libs";a:3:{i:0;s:39:"/opt/local/apache2/htdocs/cakefest/libs";i:1;s:43:"/opt/local/apache2/htdocs/cakefest/libs/log";i:2;s:46:"/opt/local/apache2/htdocs/cakefest/libs/routes";}s:43:"/opt/local/apache2/htdocs/cakephp/cake/libs";a:25:{i:0;s:43:"/opt/local/apache2/htdocs/cakephp/cake/libs";i:1;s:49:"/opt/local/apache2/htdocs/cakephp/cake/libs/cache";i:2;s:54:"/opt/local/apache2/htdocs/cakephp/cake/libs/controller";i:3;s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/controller/components";i:4;s:47:"/opt/local/apache2/htdocs/cakephp/cake/libs/log";i:5;s:49:"/opt/local/apache2/htdocs/cakephp/cake/libs/model";i:6;s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/behaviors";i:7;s:61:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources";i:8;s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources/dbo";i:9;s:48:"/opt/local/apache2/htdocs/cakephp/cake/libs/view";i:10;s:57:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements";i:11;s:63:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email";i:12;s:68:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email/html";i:13;s:68:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email/text";i:14;s:55:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/errors";i:15;s:56:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/helpers";i:16;s:56:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts";i:17;s:62:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email";i:18;s:67:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email/html";i:19;s:67:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email/text";i:20;s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/js";i:21;s:60:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/rss";i:22;s:60:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/xml";i:23;s:54:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/pages";i:24;s:58:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/scaffolds";}s:41:"/opt/local/apache2/htdocs/cakefest/models";a:1:{i:0;s:41:"/opt/local/apache2/htdocs/cakefest/models";}s:58:"/opt/local/apache2/htdocs/cakefest/plugins/lazy_model/libs";a:1:{i:0;s:58:"/opt/local/apache2/htdocs/cakefest/plugins/lazy_model/libs";}s:61:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources";a:2:{i:0;s:61:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources";i:1;s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/datasources/dbo";}s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/behaviors";a:1:{i:0;s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/model/behaviors";}s:46:"/opt/local/apache2/htdocs/cakefest/controllers";a:1:{i:0;s:46:"/opt/local/apache2/htdocs/cakefest/controllers";}s:40:"/opt/local/apache2/htdocs/cakefest/views";a:17:{i:0;s:40:"/opt/local/apache2/htdocs/cakefest/views";i:1;s:49:"/opt/local/apache2/htdocs/cakefest/views/elements";i:2;s:55:"/opt/local/apache2/htdocs/cakefest/views/elements/email";i:3;s:60:"/opt/local/apache2/htdocs/cakefest/views/elements/email/html";i:4;s:60:"/opt/local/apache2/htdocs/cakefest/views/elements/email/text";i:5;s:47:"/opt/local/apache2/htdocs/cakefest/views/events";i:6;s:52:"/opt/local/apache2/htdocs/cakefest/views/events/json";i:7;s:48:"/opt/local/apache2/htdocs/cakefest/views/layouts";i:8;s:54:"/opt/local/apache2/htdocs/cakefest/views/layouts/email";i:9;s:59:"/opt/local/apache2/htdocs/cakefest/views/layouts/email/html";i:10;s:59:"/opt/local/apache2/htdocs/cakefest/views/layouts/email/text";i:11;s:51:"/opt/local/apache2/htdocs/cakefest/views/layouts/js";i:12;s:53:"/opt/local/apache2/htdocs/cakefest/views/layouts/json";i:13;s:52:"/opt/local/apache2/htdocs/cakefest/views/layouts/rss";i:14;s:52:"/opt/local/apache2/htdocs/cakefest/views/layouts/xml";i:15;s:46:"/opt/local/apache2/htdocs/cakefest/views/pages";i:16;s:46:"/opt/local/apache2/htdocs/cakefest/views/users";}s:48:"/opt/local/apache2/htdocs/cakephp/cake/libs/view";a:16:{i:0;s:48:"/opt/local/apache2/htdocs/cakephp/cake/libs/view";i:1;s:57:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements";i:2;s:63:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email";i:3;s:68:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email/html";i:4;s:68:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/elements/email/text";i:5;s:55:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/errors";i:6;s:56:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/helpers";i:7;s:56:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts";i:8;s:62:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email";i:9;s:67:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email/html";i:10;s:67:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/email/text";i:11;s:59:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/js";i:12;s:60:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/rss";i:13;s:60:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/layouts/xml";i:14;s:54:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/pages";i:15;s:58:"/opt/local/apache2/htdocs/cakephp/cake/libs/view/scaffolds";}s:60:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/vendors";a:2:{i:0;s:60:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/vendors";i:1;s:67:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/vendors/shells";}s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/controller/components";a:1:{i:0;s:65:"/opt/local/apache2/htdocs/cakephp/cake/libs/controller/components";}s:75:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/controllers/components";a:1:{i:0;s:75:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/controllers/components";}s:58:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views";a:4:{i:0;s:58:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views";i:1;s:67:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/elements";i:2;s:66:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/helpers";i:3;s:73:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/toolbar_access";}s:66:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/helpers";a:1:{i:0;s:66:"/opt/local/apache2/htdocs/cakefest/plugins/debug_kit/views/helpers";}}
Oops, something went wrong.

0 comments on commit 689aa95

Please sign in to comment.