PHP code example of ftrotter / two-table-monolog-mysql

1. Go to this page and download the library: Download ftrotter/two-table-monolog-mysql library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ftrotter / two-table-monolog-mysql example snippets


//Import class
use TwoMySQLHandler\TwoMySQLHandler;

//Create MysqlHandler
$mySQLHandler = new TwoMySQLHandler($pdo,"log_db", "log_message", "log_context", array('username', 'userid'), \Monolog\Logger::DEBUG);

$context = ['not_sure', 'what_goes_here']; //not clear to me how this works

//Create logger
$logger = new \Monolog\Logger($context);
$logger->pushHandler($mySQLHandler);

//Now you can use the logger, and further attach additional information
$logger->addWarning("This is a great message, woohoo!", array('username'  => 'John Doe', 'userid'  => 245));