monolog mysql
Support skipping database modifications
MySQL Handler for Monolog,它允许将日志消息存储在MySQL表中。它可以将文本消息记录到特定的表格,并在表格上自动创建该表。该类进一步允许动态添加额外的属性,这些属性存储在单独的数据库字段中,可用于以后进行分析和排序。
由于我自己不再使用这个项目,而且我找不到时间来维护这个项目,因为它值得我很高兴找到有人接管它。请通过[email protected]与我联系。谢谢!
单一 - 米斯卡可通过作曲家获得。只需将以下行添加到Composer.json中所需的部分,然后进行php composer.phar update 。
"wazaari/monolog-mysql": ">1.0.0"
只需将其用作任何其他独白处理程序,就将其推入单体Logger实例的堆栈即可。但是,处理程序需要一些参数:
如果将$ skipdatabasematifications设置为true,请使用以下查询作为模板来创建日志表(如有必要,请使用其他字段)
CREATE TABLE ` log ` (
id BIGINT ( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , channel VARCHAR ( 255 ), level INTEGER , message LONGTEXT, time INTEGER UNSIGNED, INDEX(channel) USING HASH, INDEX(level) USING HASH, INDEX( time ) USING BTREE
)鉴于$ PDO是您的数据库实例,您可以使用以下类:
//Import class
use MySQLHandler MySQLHandler ;
//Create MysqlHandler
$ mySQLHandler = new MySQLHandler ( $ pdo , " log " , array ( ' username ' , ' userid ' ), Monolog Logger:: DEBUG );
//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 ));该工具是免费的软件,并根据MIT许可分配。请查看许可证文件以获取更多信息。