芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/sommatv/lib/Helper/DatabaseLogHandler.php
. */ namespace Xibo\Helper; use Monolog\Handler\AbstractProcessingHandler; use Xibo\Storage\PdoStorageService; /** * Class DatabaseLogHandler * @package Xibo\Helper */ class DatabaseLogHandler extends AbstractProcessingHandler { private static $statement; protected function write(array $record) { if (self::$statement == NULL) { $pdo = PdoStorageService::newConnection(); $SQL = 'INSERT INTO log (runNo, logdate, channel, type, page, function, message, userid, displayid) VALUES (:runNo, :logdate, :channel, :type, :page, :function, :message, :userid, :displayid) '; self::$statement = $pdo->prepare($SQL); } $params = array( 'runNo' => isset($record['extra']['uid']) ? $record['extra']['uid'] : '', 'logdate' => $record['datetime']->format("Y-m-d H:i:s"), 'type' => $record['level_name'], 'channel' => $record['channel'], 'page' => isset($record['extra']['route']) ? $record['extra']['route'] : '', 'function' => isset($record['extra']['method']) ? $record['extra']['method'] : '', 'message' => $record['message'], 'userid' => isset($record['extra']['userId']) ? $record['extra']['userId'] : 0, 'displayid' => isset($record['extra']['displayId']) ? $record['extra']['displayId'] : 0 ); try { PdoStorageService::incrementStatStatic('log', 'insert'); self::$statement->execute($params); } catch (\PDOException $e) { // Not sure what we can do here? } } }