Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed Config/.DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion Config/Schema/schema.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class DatabaseLoggerSchema extends CakeSchema {
class DatabaseLogSchema extends CakeSchema {

public function before($event = array()) {
return true;
Expand All @@ -17,6 +17,7 @@ public function after($event = array()) {
'hostname' => 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),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
/**
* DatabaseLogger Configuration file
* DatabaseLog Configuration file
*
* save the file to app/Config/database_logger.php
* save the file to app/Config/database_log.php
*/
$config = array(
'DatabaseLogger' => array(
'DatabaseLog' => array(
'write' => 'default', //DataSource to write to.
'read' => 'default', //Dadtasource to read from.
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class DatabaseLoggerAppController extends AppController {
class DatabaseLogAppController extends AppController {
protected function dataToNamed($key = 'Search'){
$params = is_array($this->request->params['named']) ? $this->request->params['named'] : array();
$data = isset($this->request->data[$key]) ? $this->request->data[$key] : array();
Expand Down
13 changes: 7 additions & 6 deletions Controller/LogsController.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
class LogsController extends DatabaseLoggerAppController {
class LogsController extends DatabaseLogAppController {

var $name = 'Logs';
var $helpers = array('Time','Icing.Csv');
//var $helpers = array('Time','Icing.Csv');
var $paginate = array(
'order' => 'Log.id DESC',
'fields' => array(
Expand All @@ -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']),
Expand Down
8 changes: 4 additions & 4 deletions Lib/Log/Engine/DatabaseLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -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{

/**
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class DatabaseLoggerAppModel extends AppModel {
class DatabaseLogAppModel extends AppModel {
var $recursive = -1;
/**
* Filter fields
Expand All @@ -18,8 +18,8 @@ class DatabaseLoggerAppModel extends AppModel {
* Set the default datasource to the read setup in config
*/
public function __construct($id = false, $table = null, $ds = null) {
if(Configure::load('database_logger')){
$this->configs = Configure::read('DatabaseLogger');
if(Configure::load('database_log')){
$this->configs = Configure::read('DatabaseLog');
}
parent::__construct($id, $table, $ds);
$this->setDataSourceRead();
Expand Down
3 changes: 2 additions & 1 deletion Model/Log.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
class Log extends DatabaseLoggerAppModel {
class Log extends DatabaseLogAppModel {
var $name = 'Log';
var $displayField = 'type';
var $searchFields = array('Log.type');
Expand All @@ -9,6 +9,7 @@ function beforeSave($options = array()){
$this->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;
}

Expand Down
4 changes: 2 additions & 2 deletions Test/Case/Model/LogTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/* Log Test cases generated on: 2011-08-08 13:46:32 : 1312832792*/
App::uses('Log', 'DatabaseLogger.Model');
App::uses('Log', 'DatabaseLog.Model');

class LogTest extends CakeTestCase {
var $fixtures = array('app.database_logger.log');
var $fixtures = array('app.database_log.log');

function startTest() {
$this->Log = ClassRegistry::init('Log');
Expand Down
2 changes: 1 addition & 1 deletion Test/Case/controllers/LogsControllerTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Logs Test cases generated on: 2011-08-08 13:47:23 : 1312832843*/
App::import('Controller', 'database_logger.Logs');
App::import('Controller', 'database_log.Logs');

class TestLogsController extends LogsController {
var $autoRender = false;
Expand Down
4 changes: 2 additions & 2 deletions Test/Case/models/LogTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/* Log Test cases generated on: 2011-08-08 13:46:32 : 1312832792*/
App::uses('Log', 'DatabaseLogger.Model');
App::uses('Log', 'DatabaseLog.Model');

class LogTest extends CakeTestCase {
var $fixtures = array('app.database_logger.log');
var $fixtures = array('app.database_log.log');

function startTest() {
$this->Log = ClassRegistry::init('Log');
Expand Down
4 changes: 2 additions & 2 deletions View/Elements/admin_filter.ctp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php echo $this->Html->script('/database_logger/js/clear_default'); ?>
<?php echo $this->Html->script('/database_log/js/clear_default'); ?>
<div id="admin_filter">
<?php
$model = isset($model) ? $model : false;

if($model){
echo $this->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();
}
?>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions View/Logs/admin_index.ctp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php echo $this->Html->css('/database_logger/css/style'); ?>
<div class="database_logger_plugin">
<?php echo $this->element('admin_filter', array('plugin' => 'database_logger', 'model' => 'Log')); ?>
<?php echo $this->Html->css('/database_log/css/style'); ?>
<div class="database_log_plugin">
<div class="logs index">
<h2><?php echo __('Logs');?></h2>
<?php echo $this->element('admin_filter', array('plugin' => 'database_log', 'model' => 'Log')); ?>
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $this->Paginator->sort('created');?></th>
Expand All @@ -29,6 +29,6 @@
</tr>
<?php endforeach; ?>
</table>
<?php echo $this->element('paging', array('plugin' => 'database_logger')); ?>
<?php echo $this->element('paging', array('plugin' => 'database_log')); ?>
</div>
</div>
9 changes: 7 additions & 2 deletions View/Logs/admin_view.ctp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php echo $this->Html->css('/database_logger/css/style'); ?>
<div class="database_logger_plugin">
<?php echo $this->Html->css('/database_log/css/style'); ?>
<div class="database_log_plugin">
<div class="logs view">
<h2><?php echo __('Log');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
Expand Down Expand Up @@ -28,6 +28,11 @@
<?php echo $log['Log']['refer']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __('User Agent'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $log['Log']['user_agent']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php echo __('Hostname'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $log['Log']['hostname']; ?>
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand All @@ -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",
Expand All @@ -24,6 +24,6 @@
"branch-alias": {
"dev-master": "2.x-dev"
},
"installer-name": "DatabaseLogger"
"installer-name": "DatabaseLog"
}
}
23 changes: 16 additions & 7 deletions readme.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Database CakePHP Plugin
* Author: Nick Baker
* Version: 1.3
* Version: 1.4.1
* License: MIT
* Website: <http://www.webtechnick.com>

Expand All @@ -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.
Expand All @@ -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.
)
Expand All @@ -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

Expand All @@ -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.
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'));
Loading