Skip to content

bayfrontmedia/monolog-pdo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monolog PDO

Monolog handler used to write log files to a MySQL database.

License

This project is open source and available under the MIT License.

Author

Bayfront Media

Requirements

  • PHP >= 8.0
  • PDO PHP extension

Installation

composer require bayfrontmedia/monolog-pdo

Usage

Before pushing this handler to a Logger instance, you must first create the necessary database table to store the records.

The table can be created using the up method, and removed using the down method.

The constructor requires a PDO instance, and the table name you wish to use:

use Bayfront\MonologPDO\PDOHandler;

/** @var PDO $pdo */
$handler = new PDOHandler($pdo, 'table_name');

$handler->up();

Once the table has been created, the handler can be pushed to a Logger instance:

use Bayfront\MonologPDO\PDOHandler;
use Monolog\Logger;

$log = new Logger('channel_name');

/** @var PDO $pdo */
$handler = new PDOHandler($pdo, 'table_name');

$log->pushHandler($handler);

From here, your log records should appear in the MySQL table.

About

Monolog handler used to write log files to a MySQL database.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages