vsemayki/monolog-mysql
Composer 安装命令:
composer require vsemayki/monolog-mysql
包简介
A handler for Monolog that sends messages to MySQL
README 文档
README
MySQL Handler for Monolog, which allows to store log messages in a MySQL table.
It can log text messages to a monolog table.
The class further is added extra attributes - channel, level, ip, created_at and user_agent, which are stored in a separate database fields, and can be used for later analyzing and sorting.
Installation
monolog-mysql is available via composer:
composer require vsemayki/monolog-mysql:^2.0
Usage
First of all, import dump.sql.
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.
- $table The table name where the logs should be stored
- $level can be any of the standard Monolog logging levels. Use Monologs statically defined contexts. Defaults to Logger::INFO
- $bubble Defaults to true
Examples
Given that $pdo is your database instance, you could use the class as follows:
<?php use MySQLHandler\MySQLHandler; $mySQLHandler = new MySQLHandler($pdo, 'monolog', $level = \Monolog\Logger::INFO, $bubble = true); // Create logger $logger = new \Monolog\Logger('db_logger'); $logger->pushHandler($mySQLHandler); // Now you can use the logger, and further attach additional information // user_id is required! $logger->addInfo('User has been created, woohoo!', ['action' => 'user/create', 'user_id' => 3562]);
License
This tool is free software and is distributed under the MIT license. Please have a look at the LICENSE file for further information.
统计信息
- 总下载量: 332
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-01-28