2017 © Pedro Peláez
 

project ci-logs

image

scissorhands/ci-logs

  • Monday, February 13, 2017
  • by scissorhands
  • Repository
  • 1 Watchers
  • 2 Stars
  • 5,318 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 4 % Grown

The README.md

ci-monolog

A simple integration of Codeigniter and Monolog, (*1)

Installation

Install using from composer composer require scissorhands/ci-logs, (*2)

Test

Edit autoload on composer.json file, (*3)

"autoload": {
    "psr-4": {
        "ciutil\\": "vendor/scissorhands/ci-utilities/",
        "cilogs\\": "vendor/scissorhands/ci-logs/"
    }
}

Add new migration file extending from library migration, (*4)

<?php
use cilogs\application\migrations\Create_logs_table as Logs_migration;
defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_Create_logs_table extends Logs_migration {

    public function __construct()
    {
        parent::__construct();
    }
}

Run migration, (*5)

Create Logger model and extend it from library model, (*6)

<?php
use cilogs\application\models\Logger_model as CILogger;
defined('BASEPATH') OR exit('No direct script access allowed');

class Logger_model extends CILogger {
    public function __construct()
    {
        parent::__construct();
    }
}

Create example controller, (*7)

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Test extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->model('logger_model', 'logger');
        $this->logger->init('testing', [
            'log_table' => 'app_logs',
            'extra_fields' => ['client_id']
        ]);
    }

    public function log2db()
    {
        $this->logger->log('Hello world', [
            'client_id' => 123456,
        ], 'info');
    }

}

Run example php index.php test log2db, (*8)

Usage

Load and init model, (*9)

$this->load->model('logger_model', 'logger');
$this->logger->init('channel_name', [
    'log_table' => 'table_name',
    /* Extra fields in case you need them */
    //'extra_fields' => ['extra_field']
]);

Log to database and files, (*10)

$this->logger->log('message_to_log', [/*extra_fields_associative_array*/], 'log_level');

The Versions

13/02 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

by Edward Scissorhands

13/02 2017
24/01 2017
24/01 2017
24/01 2017
24/01 2017
24/01 2017