2017 © Pedro Peláez
 

cakephp-plugin cakephp-databaselog

CakePHP DatabaseLog Plugin

image

assisjeferson/cakephp-databaselog

CakePHP DatabaseLog Plugin

  • Tuesday, March 20, 2018
  • by assisjeferson
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 19 Forks
  • 0 Open issues
  • 11 Versions
  • 50 % Grown

The README.md

CakePHP DatabaseLog Plugin

Build Status Coverage Status Latest Stable Version Minimum PHP Version License Total Downloads, (*1)

DatabaseLog engine for CakePHP applications., (*2)

This branch is for CakePHP 3.x, (*3)

Features

  • Easy setup and almost no dependencies.
  • Defaults to SQLite as single app application light weight approach.
  • Ideal for multi app applications where logging to a file is just not convenient.
  • If DB is used, fallback to SQLite in case the DB is not reachable.
  • Simple admin interface to view/delete logs included.
  • Basic monitoring and alert system included.
  • Export to TXT files possible.

Log Rotation

While file handling requires file log rotation and splitting into chunks of (compressed) files, a database approach can more easily keep the logs together in a single database. This is more convinient when looking through them or searching for something specific., (*4)

This plugin internally combines log entries of the exact same "content" into a single row with an increased count. Additionally you would want to add a cronjob triggered cleanup shell to keep the total size and row count below a certain threshold., (*5)

Demo

Clone and install the sandbox app, create some errors and browse the admin backend for the logs overview., (*6)

Or just attach it to your app directly. Time needed: 5 minutes., (*7)

Install

Composer (preferred)

composer require dereuromark/cakephp-databaselog

Setup

Enable the plugin in your config/bootstrap.php: php Plugin::load('DatabaseLog', ['bootstrap' => true]); or just call:, (*8)

bin/cake plugin load DatabaseLog -b

You can simply modify the existing config entries in your config/app.php: ```php 'Log' => [ 'debug' => [ 'className' => 'DatabaseLog.Database' ], 'error' => [ 'className' => 'DatabaseLog.Database' ], ],, (*9)

This will use the `database_log` connection and an SQLite file database by default, stored in your `logs` folder.

### Using an actual database (optional)
Create a config setting in your `config/app.php` what database connection it should log to:
```php
'DatabaseLog' => [
    'datasource' => 'my_datasource', // DataSource to use
]

It is recommended to not use the same datasource as your production server (default) because when the DB is not reachable logging to it will also not be possible. In that case it will fallback to SQLite file logging on this server instance, though., (*10)

Once the datasource is reachable and once the first log entry is being written, the database table (defaulting to database_logs) will be automatically created. No need to manually run any migration or SQL script here. You can also manually create the table before hand, if you prefer:, (*11)

bin/cake Migrations migrate -p DatabaseLog

Or just copy the migration file into your app /config/Migrations, modify if needed, and then run it as part of your app migrations., (*12)

Fully tested so far are PostgreSQL and MySQL, but by using the ORM all major databases should be supported., (*13)

Usage

Anywhere in your app where you call $this->log() or Log::write() the DatabaseLog engine will be used., (*14)

$this->log('This is a detailed message logged to the database', 'error');
// or
Log::write('error', 'This is a detailed message logged to the database');

There is also a browsable web backend you can view your logs with., (*15)

See docs for more details., (*16)

The Versions

20/03 2018

dev-master

9999999-dev https://github.com/assisjeferson/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

11/02 2018

2.3.4

2.3.4.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

03/01 2018

2.3.3

2.3.3.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

23/12 2017

2.3.2

2.3.2.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

23/08 2017

2.3.1

2.3.1.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

15/04 2017

2.3.0

2.3.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

08/01 2017

2.2.0

2.2.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

10/10 2016

2.1.0

2.1.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

29/09 2016

2.0.0

2.0.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin database cakephp logging logs

02/12 2014

2.x-dev

2.9999999.9999999.9999999-dev https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

  • php >=5.2.8

 

plugin database cakephp logging logs

02/12 2014

1.0

1.0.0.0 https://github.com/dereuromark/CakePHP-DatabaseLog/

CakePHP DatabaseLog Plugin

  Sources   Download

MIT

The Requires

  • php >=5.2.8

 

plugin database cakephp logging logs