Download the PHP package daoandco/cakephp-logging without Composer
On this page you can find all versions of the php package daoandco/cakephp-logging. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download daoandco/cakephp-logging
More information about daoandco/cakephp-logging
Files in daoandco/cakephp-logging
Package cakephp-logging
Short Description Cakephp plugin for Log user's action in database
License
Informations about the package cakephp-logging
Logging plugin for CakePHP 3.x
Log user's action in your Database. This plugin is composed of a Component and a Log engine. This plugin is compatible with core logs of CakePHP.
------------------------------------
This project is no longer maintained
------------------------------------
Requirements
- PHP version 5.4.16 or higher
- CakePhp 3.0 or higher
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
Loading the Plugin like that
Create table log : execute shema in config/shema/logs.sql
(you can change the table name)
Quick Start
If you want just replace default config you can change Log's config in your app
file
For writing to logs see http://book.cakephp.org/3.0/en/core-libraries/logging.html#writing-to-logs
Or you can use LogComponent in your controllers. The component store by default request
and session
in context field.
Configuration
Options
- className :
'Logging.Database'
- model : Model name (default:
'Logging.Logs'
) - table : table name (default:
'logs'
) - levels : logging levels (default:
'[]'
= all levels) More infos - scopes: logging scopes (default:
'[]'
= all scopes) More infos - requiredScope : if true no store logs if scope is empty (default
false
) - userId : path where is stored user id in Session (default
Auth.User.id
)
Use cases
Edit config/app.php
Write everything with the plugin
Write cake log in file and write application log with the plugin
With this configuration the scope is required when you write in a log
Writing to Logs :
Component
Configuration
- request: if true store
$this->request
in Context (default:'false'
) - session: if true store
$_SESSION
Context (default:'false'
) - ip: if true store
$this->request->clientIp()
Context (default:'false'
) - referer: if true store
$this->request->referer()
Context (default:'false'
) - vars: store more datas (ex :
['plugin' => $this->plugin]
Methods
-
write($level, $scope, $message, $context, $config)
Log a message -
emergency($scope, $message, $context, $config)
Log a emergency message -
alert($scope, $message, $context, $config)
Log a alert message -
critical($scope, $message, $context, $config)
Log a critical message -
error($scope, $message, $context, $config)
Log a error message -
warning($scope, $message, $context, $config)
Log a warning message -
notice($scope, $message, $context, $config)
Log a notice message -
debug($scope, $message, $context, $config)
Log a debug message info($scope, $message, $context, $config)
Log a info message
Parameters
- levels : (string) logging levels (
'emergency'|'alert'|'critical'|'error'|'warning'|'notice'|'debug'|'info'
) More infos - scope : (string|array) logging scopes More infos
- message: (string) log message
- context: (array) Additional data to be used for logging the message
- config: change base config (ex request, session...)