moharram82/monolog

Sends your logs to files, sockets, inboxes, databases and various web services

1.24.0 2018-11-20 17:35 UTC

README

Monolog sends your logs to files, sockets, inboxes, databases and various web services.

This is a fork from (https://github.com/Seldaek/monolog) with the following features:

  • Adds MySQL database support through:
    • PDO extension (PDOHandler).
    • mysqli extension (MySQLiHandler).

Installation

Install the latest version with

$ composer require moharam82/monolog

Basic Usage

<?php

use Monolog\Logger;
use Monolog\Handler\StreamHandler;
use Monolog\Handler\PDOHandler;
use Monolog\Handler\MySQLiHandler;

// database table to be created to store logs, if not provided will default to monolog
$table = 'logs';

// create a log channel
$log = new Logger('name');

// add a file handler to the logger
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));

// add PDO as a handler to the logger
$log->pushHandler(new PDOHandler(\PDO $pdo, $table, Logger::WARNING, true));

// add mysqli as a handler to the logger
$log->pushHandler(new MySQLiHandler(\mysqli $mysqli, $table, Logger::WARNING, true));

// add records to the log
$log->warn('Test log message');

For the original README visit (https://github.com/Seldaek/monolog).

Changelog 1.24.0 (2018-11-20)

  • Updated the monolog library to version 1.24.0
  • Updated the PDOHandler & MySQLiHandler to create a new logs table structure.
  • The table name parameter now comes second after the database connection object, so pay attention when instantiating the handler object.

For the complete v1.24.0 changelog see (https://github.com/Seldaek/monolog/blob/master/CHANGELOG.md).