diff --git a/Config/.DS_Store b/Config/.DS_Store
deleted file mode 100644
index aad9ba9..0000000
Binary files a/Config/.DS_Store and /dev/null differ
diff --git a/Config/Schema/schema.php b/Config/Schema/schema.php
index 09d7c52..c453dba 100644
--- a/Config/Schema/schema.php
+++ b/Config/Schema/schema.php
@@ -1,5 +1,5 @@
array('type' => 'string', 'null' => true, 'default' => null, 'length' => 50, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'uri' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'refer' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
+ 'user_agent' => array('type' => 'text', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'indexes' => array(
'PRIMARY' => array('column' => 'id', 'unique' => 1),
'type' => array('column' => 'type', 'unique' => 0),
diff --git a/Config/database_logger.php.example b/Config/database_log.php.example
similarity index 55%
rename from Config/database_logger.php.example
rename to Config/database_log.php.example
index 6b8baec..9ebbd25 100644
--- a/Config/database_logger.php.example
+++ b/Config/database_log.php.example
@@ -1,11 +1,11 @@
array(
+ 'DatabaseLog' => array(
'write' => 'default', //DataSource to write to.
'read' => 'default', //Dadtasource to read from.
)
diff --git a/Controller/DatabaseLoggerAppController.php b/Controller/DatabaseLogAppController.php
similarity index 84%
rename from Controller/DatabaseLoggerAppController.php
rename to Controller/DatabaseLogAppController.php
index 8bb856b..dbaf39a 100644
--- a/Controller/DatabaseLoggerAppController.php
+++ b/Controller/DatabaseLogAppController.php
@@ -1,5 +1,5 @@
request->params['named']) ? $this->request->params['named'] : array();
$data = isset($this->request->data[$key]) ? $this->request->data[$key] : array();
diff --git a/Controller/LogsController.php b/Controller/LogsController.php
index 3465d2d..b11fbca 100644
--- a/Controller/LogsController.php
+++ b/Controller/LogsController.php
@@ -1,8 +1,8 @@
'Log.id DESC',
'fields' => array(
@@ -29,13 +29,14 @@ function admin_index($filter = null) {
}
function admin_export($filter = null){
- $this->layout = 'csv';
+ //$this->layout = 'csv';
+ $this->layout = false;
if(!empty($this->data)){
$filter = $this->data['Log']['filter'];
}
- if($this->RequestHandler->ext != 'csv'){
- $this->redirect(array('action' => 'export', 'ext' => 'csv', $filter));
- }
+ //if($this->RequestHandler->ext != 'csv'){
+ // $this->redirect(array('action' => 'export', 'ext' => 'csv', $filter));
+ //}
$this->dataToNamed();
$conditions = array_merge(
$this->Log->search($this->request->params['named']),
diff --git a/Lib/Log/Engine/DatabaseLog.php b/Lib/Log/Engine/DatabaseLog.php
index 5c68021..96716c5 100755
--- a/Lib/Log/Engine/DatabaseLog.php
+++ b/Lib/Log/Engine/DatabaseLog.php
@@ -10,14 +10,14 @@
in app/config/bootstrap.php add the following
CakeLog::config('database', array(
- 'engine' => 'DatabaseLogger.DatabaseLogger',
- 'model' => 'CustomLogModel' //'DatabaseLogger.Log' by default
+ 'engine' => 'DatabaseLog.DatabaseLog',
+ 'model' => 'CustomLogModel' //'DatabaseLog.Log' by default
));
*/
App::uses('ClassRegistry', 'Utility');
App::uses('CakeLogInterface','Log');
-App::uses('Log', 'DatabaseLogger.Model');
+App::uses('Log', 'DatabaseLog.Model');
class DatabaseLog implements CakeLogInterface{
/**
@@ -34,7 +34,7 @@ class DatabaseLog implements CakeLogInterface{
* Contruct the model class
*/
function __construct($options = array()){
- $this->model = isset($options['model']) ? $options['model'] : 'DatabaseLogger.Log';
+ $this->model = isset($options['model']) ? $options['model'] : 'DatabaseLog.Log';
$this->Log = ClassRegistry::init($this->model);
}
diff --git a/Model/DatabaseLoggerAppModel.php b/Model/DatabaseLogAppModel.php
similarity index 97%
rename from Model/DatabaseLoggerAppModel.php
rename to Model/DatabaseLogAppModel.php
index bafbf45..69192d4 100644
--- a/Model/DatabaseLoggerAppModel.php
+++ b/Model/DatabaseLogAppModel.php
@@ -1,5 +1,5 @@
configs = Configure::read('DatabaseLogger');
+ if(Configure::load('database_log')){
+ $this->configs = Configure::read('DatabaseLog');
}
parent::__construct($id, $table, $ds);
$this->setDataSourceRead();
diff --git a/Model/Log.php b/Model/Log.php
index daf64e9..61f633f 100755
--- a/Model/Log.php
+++ b/Model/Log.php
@@ -1,5 +1,5 @@
data[$this->alias]['hostname'] = env('HTTP_HOST');
$this->data[$this->alias]['uri'] = env('REQUEST_URI');
$this->data[$this->alias]['refer'] = env('HTTP_REFERER');
+ $this->data[$this->alias]['user_agent'] = env('HTTP_USER_AGENT');
return true;
}
diff --git a/Test/Case/Model/LogTest.php b/Test/Case/Model/LogTest.php
index a0a9b56..bb9f185 100755
--- a/Test/Case/Model/LogTest.php
+++ b/Test/Case/Model/LogTest.php
@@ -1,9 +1,9 @@
Log = ClassRegistry::init('Log');
diff --git a/Test/Case/controllers/LogsControllerTest.php b/Test/Case/controllers/LogsControllerTest.php
index 619b8dc..ca437a0 100755
--- a/Test/Case/controllers/LogsControllerTest.php
+++ b/Test/Case/controllers/LogsControllerTest.php
@@ -1,6 +1,6 @@
Log = ClassRegistry::init('Log');
diff --git a/View/Elements/admin_filter.ctp b/View/Elements/admin_filter.ctp
index e70a066..735e9ca 100755
--- a/View/Elements/admin_filter.ctp
+++ b/View/Elements/admin_filter.ctp
@@ -1,4 +1,4 @@
-Html->script('/database_logger/js/clear_default'); ?>
+Html->script('/database_log/js/clear_default'); ?>
Form->create($model, array('inputDefaults' => array('label' => false,'div' => false)));
echo $this->Form->input('filter', array('label' => false, 'value' => "$model Search", 'class' => 'clear_default'));
- echo $this->Form->submit('/database_logger/img/search_button.gif', array('div' => false));
+ echo $this->Form->submit('/database_log/img/search_button.gif', array('div' => false));
echo $this->Form->end();
}
?>
diff --git a/View/Helpers/CsvHelper.php b/View/Helper/CsvHelper.php
similarity index 100%
rename from View/Helpers/CsvHelper.php
rename to View/Helper/CsvHelper.php
diff --git a/View/Helpers/empty b/View/Helper/empty
similarity index 100%
rename from View/Helpers/empty
rename to View/Helper/empty
diff --git a/View/Logs/csv/admin_export.ctp b/View/Logs/admin_export.ctp
old mode 100755
new mode 100644
similarity index 100%
rename from View/Logs/csv/admin_export.ctp
rename to View/Logs/admin_export.ctp
diff --git a/View/Logs/admin_index.ctp b/View/Logs/admin_index.ctp
index 74c98ff..a3988c4 100755
--- a/View/Logs/admin_index.ctp
+++ b/View/Logs/admin_index.ctp
@@ -1,8 +1,8 @@
-Html->css('/database_logger/css/style'); ?>
-
- element('admin_filter', array('plugin' => 'database_logger', 'model' => 'Log')); ?>
+Html->css('/database_log/css/style'); ?>
+
+ element('admin_filter', array('plugin' => 'database_log', 'model' => 'Log')); ?>
| Paginator->sort('created');?> |
@@ -29,6 +29,6 @@
- element('paging', array('plugin' => 'database_logger')); ?>
+ element('paging', array('plugin' => 'database_log')); ?>
\ No newline at end of file
diff --git a/View/Logs/admin_view.ctp b/View/Logs/admin_view.ctp
index 1701a5f..dcc0549 100755
--- a/View/Logs/admin_view.ctp
+++ b/View/Logs/admin_view.ctp
@@ -1,5 +1,5 @@
-Html->css('/database_logger/css/style'); ?>
-
+Html->css('/database_log/css/style'); ?>
+
@@ -28,6 +28,11 @@
+ - >
+ - >
+
+
+
- >
- >
diff --git a/composer.json b/composer.json
index a6211ab..1f63288 100644
--- a/composer.json
+++ b/composer.json
@@ -3,7 +3,7 @@
"description": "CakePHP Database Logger Plugin",
"type": "cakephp-plugin",
"keywords": ["cakephp", "database", "logging", "logs", "plugin"],
- "homepage": "https://github.com/webtechnick/CakePHP-DatabaseLogger-Plugin",
+ "homepage": "https://github.com/webtechnick/CakePHP-DatabaseLog-Plugin",
"license": "MIT",
"authors": [
{
@@ -13,8 +13,8 @@
}
],
"support": {
- "issues": "https://github.com/webtechnick/CakePHP-DatabaseLogger-Plugin/issues",
- "source": "https://github.com/webtechnick/CakePHP-DatabaseLogger-Plugin"
+ "issues": "https://github.com/webtechnick/CakePHP-DatabaseLog-Plugin/issues",
+ "source": "https://github.com/webtechnick/CakePHP-DatabaseLog-Plugin"
},
"require": {
"php": ">=5.2.0",
@@ -24,6 +24,6 @@
"branch-alias": {
"dev-master": "2.x-dev"
},
- "installer-name": "DatabaseLogger"
+ "installer-name": "DatabaseLog"
}
}
\ No newline at end of file
diff --git a/readme.markdown b/readme.markdown
index 8271fe9..d90b2ed 100644
--- a/readme.markdown
+++ b/readme.markdown
@@ -1,6 +1,6 @@
# Database CakePHP Plugin
* Author: Nick Baker
-* Version: 1.3
+* Version: 1.4.1
* License: MIT
* Website:
@@ -10,6 +10,7 @@ Database CakeLogger for CakePHP 2.x applications. Easy setup. Ideal for multi
is just not convinient. Simple admin interface to view/delete logs included.
## Changelog
+* 1.4.1 Compatible with CakePHP 2.4. Field user_agent added. Fix CSV export.
* 1.4.0 Compatible with CakePHP 2.4
* 1.3.0 New configuration file to change default read, write datasources.
* 1.2.0 Now using FULLTEXT search on messages, better indexes. Update your schema.
@@ -18,20 +19,24 @@ is just not convinient. Simple admin interface to view/delete logs included.
## Install
-Clone the repository into your `app/Plugin/DatabaseLogger` directory:
+Clone the repository into your `app/Plugin/DatabaseLog` directory:
- $ git clone git://github.com/webtechnick/CakePHP-DatabaseLogger-Plugin.git app/Plugin/DatabaseLogger
+ $ git clone git://github.com/webtechnick/CakePHP-DatabaseLogger-Plugin.git app/Plugin/DatabaseLog
Run the schema into your database:
$ cake schema create --plugin DatabaseLog
+Load plugin in bootstrap.php
+
+ CakePlugin::load('DatabaseLog');
+
## Setup
-Create a config file in `app/Config/database_logger` with the following (example file in plugin.)
+Create a config file in `app/Config/database_log` with the following (example file in plugin.)
$config = array(
- 'DatabaseLogger' => array(
+ 'DatabaseLog' => array(
'write' => 'default', //DataSource to write to.
'read' => 'default', //Datasource to read from.
)
@@ -42,7 +47,7 @@ Pro Tip: You can read from a different datasource than you write to, and they bo
Update the file `app/Config/bootstrap.php` with the following configurations like so:
App::uses('CakeLog','Log');
- CakeLog::config('default', array('engine' => 'DatabaseLogger.DatabaseLogger'));
+ CakeLog::config('default', array('engine' => 'DatabaseLog.DatabaseLog'));
## Usage
@@ -51,4 +56,8 @@ Anywhere in your app where you call log() or CakeLog::write the database logger
$this->log('This is a detailed message logged to the database','error');
CakeLog::write('error', 'This is a detailed message logged to the database');
-Navigate to `http://www.example.com/admin/database_logger/logs` to view/search/delete your logs.
\ No newline at end of file
+Navigate to `http://www.example.com/admin/database_log/logs` to view/search/delete your logs.
+
+Warning: you should have added admin prefix for routes.
+
+ Configure::write('Routing.prefixes', array('admin'));
diff --git a/webroot/css/style.css b/webroot/css/style.css
index 49f8476..0746c7e 100644
--- a/webroot/css/style.css
+++ b/webroot/css/style.css
@@ -1,27 +1,27 @@
/** containers **/
-div.database_logger_plugin div.form,
-div.database_logger_plugin div.index,
-div.database_logger_plugin div.view {
+div.database_log_plugin div.form,
+div.database_log_plugin div.index,
+div.database_log_plugin div.view {
border-left:1px solid #666;
padding:10px 2%;
min-height: 300px;
}
-div.database_logger_plugin div.actions {
+div.database_log_plugin div.actions {
float:left;
width:16%;
padding:10px 1.5%;
}
-div.database_logger_plugin div.actions h3 {
+div.database_log_plugin div.actions h3 {
padding-top:0;
color:#777;
}
-div.database_logger_plugin #admin_filter form input[type="image"]{
+div.database_log_plugin #admin_filter form input[type="image"]{
position: relative;
top: 10px;
}
/** Tables **/
-div.database_logger_plugin table {
+div.database_log_plugin table {
background: #fff;
border-right:0;
clear: both;
@@ -29,186 +29,186 @@ div.database_logger_plugin table {
margin-bottom: 10px;
width: 100%;
}
-div.database_logger_plugin th {
+div.database_log_plugin th {
border:0;
border-bottom:2px solid #555;
text-align: left;
padding:4px;
}
-div.database_logger_plugin th a {
+div.database_log_plugin th a {
display: block;
padding: 2px 4px;
text-decoration: none;
}
-div.database_logger_plugin th a.asc:after {
+div.database_log_plugin th a.asc:after {
content: ' ⇣';
}
-div.database_logger_plugin th a.desc:after {
+div.database_log_plugin th a.desc:after {
content: ' ⇡';
}
-div.database_logger_plugin table tr td {
+div.database_log_plugin table tr td {
background: #fff;
padding: 6px;
text-align: left;
vertical-align: top;
border-bottom:1px solid #ddd;
}
-div.database_logger_plugin table tr:nth-child(2n) td {
+div.database_log_plugin table tr:nth-child(2n) td {
background: #f5f5f5;
}
-div.database_logger_plugin table .altrow td {
+div.database_log_plugin table .altrow td {
background: #f5f5f5;
}
-div.database_logger_plugin td.actions {
+div.database_log_plugin td.actions {
text-align: center;
white-space: nowrap;
}
-div.database_logger_plugin table td.actions a {
+div.database_log_plugin table td.actions a {
margin: 0px 6px;
padding:2px 5px;
}
/** Paging **/
-div.database_logger_plugin div.paging {
+div.database_log_plugin div.paging {
background:#fff;
color: #ccc;
margin-top: 1em;
clear:both;
}
-div.database_logger_plugin div.paging span.disabled {
+div.database_log_plugin div.paging span.disabled {
color: #ddd;
display: inline;
}
-div.database_logger_plugin div.paging span.current {
+div.database_log_plugin div.paging span.current {
color: #c73e14;
}
-div.database_logger_plugin div.paging span a {
+div.database_log_plugin div.paging span a {
}
/** Scaffold View **/
-div.database_logger_plugin dl {
+div.database_log_plugin dl {
line-height: 2em;
margin: 0em 0em;
width: 60%;
}
-div.database_logger_plugin dl .altrow {
+div.database_log_plugin dl .altrow {
background: #f4f4f4;
}
-div.database_logger_plugin dt {
+div.database_log_plugin dt {
font-weight: bold;
padding-left: 4px;
vertical-align: top;
}
-div.database_logger_plugin dd {
+div.database_log_plugin dd {
margin-left: 10em;
margin-top: -2em;
vertical-align: top;
}
/** Forms **/
-div.database_logger_plugin form {
+div.database_log_plugin form {
clear: both;
margin-right: 20px;
padding: 0;
width: 95%;
}
-div.database_logger_plugin fieldset {
+div.database_log_plugin fieldset {
border: 1px solid #ccc;
margin-bottom: 1em;
padding: 16px 20px;
}
-div.database_logger_plugin fieldset legend {
+div.database_log_plugin fieldset legend {
background:#fff;
color: #e32;
font-size: 160%;
font-weight: bold;
}
-div.database_logger_plugin fieldset fieldset {
+div.database_log_plugin fieldset fieldset {
margin-top: 0px;
margin-bottom: 20px;
padding: 16px 10px;
}
-div.database_logger_plugin fieldset fieldset legend {
+div.database_log_plugin fieldset fieldset legend {
font-size: 120%;
font-weight: normal;
}
-div.database_logger_plugin fieldset fieldset div {
+div.database_log_plugin fieldset fieldset div {
clear: left;
margin: 0 20px;
}
-div.database_logger_plugin form div {
+div.database_log_plugin form div {
clear: both;
margin-bottom: 1em;
padding: .5em;
vertical-align: text-top;
}
-div.database_logger_plugin form .input {
+div.database_log_plugin form .input {
color: #444;
}
-div.database_logger_plugin form .required {
+div.database_log_plugin form .required {
font-weight: bold;
}
-div.database_logger_plugin form .required label:after {
+div.database_log_plugin form .required label:after {
color: #e32;
content: '*';
display:inline;
}
-div.database_logger_plugin form div.submit {
+div.database_log_plugin form div.submit {
border: 0;
clear: both;
margin-top: 10px;
}
-div.database_logger_plugin label {
+div.database_log_plugin label {
display: block;
font-size: 110%;
margin-bottom:3px;
}
-div.database_logger_plugin input, div.database_logger_plugin textarea {
+div.database_log_plugin input, div.database_log_plugin textarea {
clear: both;
font-size: 140%;
font-family: "frutiger linotype", "lucida grande", "verdana", sans-serif;
padding: 1%;
width:98%;
}
-div.database_logger_plugin #admin_filter input {
+div.database_log_plugin #admin_filter input {
clear: none;
width: auto;
}
-div.database_logger_plugin select {
+div.database_log_plugin select {
clear: both;
font-size: 120%;
vertical-align: text-bottom;
}
-div.database_logger_plugin select[multiple=multiple] {
+div.database_log_plugin select[multiple=multiple] {
width: 100%;
}
-div.database_logger_plugin option {
+div.database_log_plugin option {
font-size: 120%;
padding: 0 3px;
}
-div.database_logger_plugin input[type=checkbox] {
+div.database_log_plugin input[type=checkbox] {
clear: left;
float: left;
margin: 0px 6px 7px 2px;
width: auto;
}
-div.database_logger_plugin div.checkbox label {
+div.database_log_plugin div.checkbox label {
display: inline;
}
-div.database_logger_plugin input[type=radio] {
+div.database_log_plugin input[type=radio] {
float:left;
width:auto;
margin: 0 3px 7px 0;
}
-div.database_logger_plugin div.radio label {
+div.database_log_plugin div.radio label {
margin: 0 0 6px 20px;
}
-div.database_logger_plugin input[type=submit] {
+div.database_log_plugin input[type=submit] {
display: inline;
font-size: 110%;
width: auto;
}
-div.database_logger_plugin form .submit input[type=submit] {
+div.database_log_plugin form .submit input[type=submit] {
background:#62af56;
background: -webkit-gradient(linear, left top, left bottom, from(#a8ea9c), to(#62af56));
background-image: -moz-linear-gradient(top, #a8ea9c, #62af56);
@@ -216,14 +216,14 @@ div.database_logger_plugin form .submit input[type=submit] {
color: #000;
text-shadow: #8cee7c 0px 1px 0px;
}
-div.database_logger_plugin form .submit input[type=submit]:hover {
+div.database_log_plugin form .submit input[type=submit]:hover {
background:#4ca83d;
background: -webkit-gradient(linear, left top, left bottom, from(#85e573), to(#4ca83d));
background-image: -moz-linear-gradient(top, #85e573, #4ca83d);
}
/** Notices and Errors **/
-div.database_logger_plugin div.message {
+div.database_log_plugin div.message {
clear: both;
color: #fff;
font-size: 140%;
@@ -232,13 +232,13 @@ div.database_logger_plugin div.message {
background: #c73e14;
padding: 5px;
}
-div.database_logger_plugin div.error-message {
+div.database_log_plugin div.error-message {
clear: both;
color: #fff;
font-weight: bold;
background: #c73e14;
}
-div.database_logger_plugin p.error {
+div.database_log_plugin p.error {
background-color: #e32;
color: #fff;
font-family: Courier, monospace;
@@ -247,12 +247,12 @@ div.database_logger_plugin p.error {
padding: 0.8em;
margin: 1em 0;
}
-div.database_logger_plugin p.error em {
+div.database_log_plugin p.error em {
color: #000;
font-weight: normal;
line-height: 140%;
}
-div.database_logger_plugin .notice {
+div.database_log_plugin .notice {
background: #ffcc00;
color: #000;
display: block;
@@ -262,34 +262,34 @@ div.database_logger_plugin .notice {
padding: 0.8em;
margin: 1em 0;
}
-div.database_logger_plugin .success {
+div.database_log_plugin .success {
background: green;
color: #fff;
}
/** Actions **/
-div.database_logger_plugin div.actions ul {
+div.database_log_plugin div.actions ul {
margin: 0;
padding: 0;
}
-div.database_logger_plugin div.actions li {
+div.database_log_plugin div.actions li {
margin:0 0 0.5em 0;
list-style-type: none;
white-space: nowrap;
padding: 0;
}
-div.database_logger_plugin div.actions ul li a {
+div.database_log_plugin div.actions ul li a {
font-weight: normal;
display: block;
clear: both;
}
-div.database_logger_plugin div.actions ul li a:hover {
+div.database_log_plugin div.actions ul li a:hover {
text-decoration: underline;
}
-div.database_logger_plugin input[type=submit],
-div.database_logger_plugin div.actions ul li a,
-div.database_logger_plugin td.actions a {
+div.database_log_plugin input[type=submit],
+div.database_log_plugin div.actions ul li a,
+div.database_log_plugin td.actions a {
font-weight:normal;
padding: 4px 8px;
background:#e6e49f;
@@ -304,15 +304,15 @@ div.database_logger_plugin td.actions a {
text-shadow: #fff 0px 1px 0px;
min-width: 0;
}
-div.database_logger_plugin input[type=submit]:hover,
-div.database_logger_plugin div.actions ul li a:hover,
-div.database_logger_plugin td.actions a:hover {
+div.database_log_plugin input[type=submit]:hover,
+div.database_log_plugin div.actions ul li a:hover,
+div.database_log_plugin td.actions a:hover {
background: #f0f09a;
background: -webkit-gradient(linear, left top, left bottom, from(#f7f7e1), to(#eeeca9));
}
/** Related **/
-div.database_logger_plugin div.related {
+div.database_log_plugin div.related {
clear: both;
display: block;
}
\ No newline at end of file