Welcome Guest, Not a member yet? Register   Sign In
PHP Error Log Library (Database)
#1

[eluser]appleboy[/eluser]
It is available on Github. https://github.com/appleboy/CodeIgniter-Log-Library

We can store all error message into database.

Installation

Create log table on your database. SQL structure is available on sql/mysql.sql

Code:
--
-- Table structure for table `logs`
--

DROP TABLE IF EXISTS `logs`;
CREATE TABLE IF NOT EXISTS `logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `errno` int(2) NOT NULL,
  `errtype` varchar(32) CHARACTER SET utf8 NOT NULL,
  `errstr` text CHARACTER SET utf8 NOT NULL,
  `errfile` varchar(255) CHARACTER SET utf8 NOT NULL,
  `errline` int(4) NOT NULL,
  `time` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

You can install via codeigniter spark or step by step from following instruction.

Code:
$ cp config/log.php your_application/config/
$ cp libraries/Lib_log.php your_application/libraries/
$ cp controllers/example.php your_application/controllers/

You can install via http://getsparks.org/packages/codeigniter-log/show

Code:
$ php tools/spark install -v1.0.0 codeigniter-log

Finally excute via command line.

Code:
$ php index.php example

Usage

load library from spark:

Code:
$this->load->spark('codeigniter-log/1.0.0');

or load library from codeigniter loader

Code:
$this->load->library('lib_log');

log message from trigger_error function.

Code:
trigger_error("User error via trigger.", E_USER_ERROR);
trigger_error("Warning error via trigger.", E_USER_WARNING);
trigger_error("Notice error via trigger.", E_USER_NOTICE);

use php exception:

Code:
throw new Exception('Error: Division by zero.', E_USER_ERROR);

Please refer the example controller (controllers/example.php).

Screenshot

https://farm9.staticflickr.com/8077/8431...fc05_c.jpg
#2

[eluser]quickshiftin[/eluser]
Nice work!




Theme © iAndrew 2016 - Forum software by © MyBB