ftrotter/two-table-monolog-mysql 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ftrotter/two-table-monolog-mysql

Composer 安装命令:

composer require ftrotter/two-table-monolog-mysql

包简介

A handler for Monolog that sends messages to MariaDB (or MySQL), split between two tables

README 文档

README

This is a fork of the monolog-mysql project to implement two important features that I need:

  • Specify the database, and not just the table(s) on setup.
  • Logs to two different tables, one for the messages and another for the context arrays.

Installation

monolog-mysql is available via composer. Just add the following line to your required section in composer.json and do a php composer.phar update.

"ftrotter/two-table-monolog-mysql": ">0.0.1"

Usage

Just use it as any other Monolog Handler, push it to the stack of your Monolog Logger instance. The Handler however needs some parameters:

  • $pdo PDO Instance of your database. Pass along the PDO instantiation of your database connection with your database selected.
  • $database The name of the database where the logs should be stored
  • $message_table The table name where the message logs should be stored
  • $context_table The table name where the context logs should be stored
  • $level can be any of the standard Monolog logging levels. Use Monologs statically defined contexts. Defaults to Logger::DEBUG
  • $bubble Defaults to true

Examples

Given that $pdo is your database instance, you could use the class as follows:

//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));

License

This tool is free software and is distributed under the MIT license. Please have a look at the LICENSE file for further information.

统计信息

  • 总下载量: 288
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 82
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-09-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固