cinghie/yii2-logger

Yii2 Logger to create log to Database or File in a Yii2 site.

Installs: 147

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Open Issues: 0

Type:yii2-extension

dev-main 2023-05-24 14:09 UTC

This package is auto-updated.

Last update: 2024-10-24 17:21:13 UTC


README

License Latest Stable Version Latest Release Date Latest Commit Total Downloads

Yii2 Extension to log action to database or file

Installation

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require cinghie/yii2-logger "*"

or add

"cinghie/yii2-logger": "*"

2. Update database schema

Run the following command:

$ php yii migrate/up --migrationPath=@vendor/cinghie/yii2-logger/migrations

Configuration

Add in your common configuration file:

use cinghie\logger\Logger;

'modules' => [

    // Yii2 Loggers
    'logger' => [
        'class' => Logger::class,
    ],
    
],

Use Logger

use cinghie\logger\models\Loggers;

$logger = new Loggers();
$logger->entity_name = 'EntityName';
$logger->entity_id = 'EntityID';
$logger->action = 'ActionName';
$logger->created_by = NULL;
$logger->entity_name = date('Y-m-d H:i:s');
$logger->data = 'DATA CONTENT';
$logger->ip = Yii::app()->request->getUserHostAddress();
$logger->save();