webtechnick/cakephp-database-logger-plugin

CakePHP Database Logger Plugin

dev-master / 2.x-dev 2015-03-02 18:30 UTC

This package is not auto-updated.

Last update: 2024-04-27 12:56:47 UTC


README

Features

Database CakeLogger for CakePHP 2.x applications. Easy setup. Ideal for multi app applications where logging to a file is just not convinient. Simple admin interface to view/delete logs included.

Changelog

  • 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.
  • 1.1.0 Adding new fields URI, hostname, referrer, and IP automatically logged on each log call. (only applys to default Log model)
  • 1.0.0 Initial Release

Install

Clone the repository into your app/Plugin/DatabaseLogger directory:

$ git clone git://github.com/webtechnick/CakePHP-DatabaseLogger-Plugin.git app/Plugin/DatabaseLogger

Run the schema into your database:

$ cake schema create --plugin DatabaseLogger

Setup

Create a config file in app/Config/database_logger with the following (example file in plugin.)

$config = array(
	'DatabaseLogger' => array(
		'write' => 'default', //DataSource to write to.
		'read' => 'default', //Datasource to read from.
	)
);

Pro Tip: You can read from a different datasource than you write to, and they both can be different than your default.

Update the file app/Config/bootstrap.php with the following configurations like so:

App::uses('CakeLog','Log');
CakeLog::config('default', array('engine' => 'DatabaseLogger.DatabaseLog'));

Usage

Anywhere in your app where you call log() or CakeLog::write the database logger will be used.

	$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.