Skip to content
This repository has been archived by the owner on Jan 4, 2019. It is now read-only.

nexeck/kohana-dblog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kohana database log writer

Status

Beta

Requirements

Installation

Register the module in bootstrap.php:

Kohana::modules(array(
	[...]
	'dblog' => MODPATH.'dblog',
));

Create a database table, based on default.sql. Additional fields can be added.

If you want to store all Kohana::$log messages in the database too:

In bootstrap.php change

Kohana::$log->attach(new Kohana_Log_File(APPPATH.'logs'));

to

Kohana::$log->attach(new DBlog_Writer());

Make sure this line appears after the call of Kohana::modules().

Basic usage

DBlog::add('NOTICE', 'Log demo title', 'Log demo details: :params', array(':params' => chr(10).print_r($_GET, TRUE)));

Using additional fields

DBlog::add('category', 'title', 'details', array(), array(
	'client_ip' => getenv('REMOTE_ADDR'),
	'url' => getenv('REQUEST_URI'),
));

Configuration (optional)

  • Copy modules/dblog/config/dblog.php to application/config/
  • You can change the log table name and pagination settings

Controller / rendering the log table

The controller should not be accessed directly. You can embed it in your controller with an internal request.

Example with Controller_Demo:

$this->template->content = Request::factory('dblog/index')->execute()->response;

Ignoring certain log types

You can omit log entries of certain types (e.g. in production environments) by setting the static $omit_types property.

Example in bootstrap.php:

if (Kohana::$environment === Kohana::PRODUCTION)
{
	DBlog::$omit_types = array('NOTICE');
}

License

ISC License

About

Kohana 3 database log writer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages