Coder Social home page Coder Social logo

codeigniter-log-library's Introduction

CodeIgniter-Log-Library

Store all php error or exception logs into database.

Installation

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

--
-- 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) NOT NULL,
  `errstr` text NOT NULL,
  `errfile` varchar(255) NOT NULL,
  `errline` int(4) NOT NULL,
  `user_agent` varchar(120) NOT NULL,
  `ip_address` varchar(45) DEFAULT '0' NOT NULL,
  `time` datetime NOT NULL,
  PRIMARY KEY (`id`, `ip_address`, `user_agent`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8;

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

$ 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

$ php tools/spark install -v1.0.1 codeigniter-log

Finally excute via command line.

$ php index.php example

Usage

load library from spark:

$this->load->spark('codeigniter-log/1.0.1');

or load library from codeigniter loader

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

log message from trigger_error function.

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:

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

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

Screenshot

mysql log

codeigniter-log-library's People

Contributors

appleboy avatar howtomakeaturn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.