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許可分配。請查看許可證文件以獲取更多信息。