zoukankan      html  css  js  c++  java
  • monolog php

    include_once IA_ROOT . '/lib/log/PDOHandler.php';

    use MonologLogger;
     

    $loger = new Logger('name');

    $pdo = new PDO('mysql:host=xxxxx;dbname=weishop;charset=utf8', 'username', 'password');
    $dd = new PDOHandler($pdo);
    $loger->pushHandler($dd);
    $loger->addInfo('My logger is now ready');
    $loger->debug("debug info2222");
    class PDOHandler extends AbstractProcessingHandler { private $initialized = false; private $pdo; private $statement; public function __construct(PDO $pdo, $level = Logger::DEBUG, $bubble = true) { $this->pdo = $pdo; parent::__construct($level, $bubble); } protected function write(array $record) { if (!$this->initialized) { $this->initialize(); } $this->statement->execute(array( 'channel' => $record['channel'], 'level' => $record['level'], 'message' => $record['formatted'], 'time' => $record['datetime']->format('U'), )); } private function initialize() { $this->pdo->exec( 'CREATE TABLE IF NOT EXISTS monolog ' .'(channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED)' ); $this->statement = $this->pdo->prepare( 'INSERT INTO monolog (channel, level, message, time) VALUES (:channel, :level, :message, :time)' ); $this->initialized = true; } }
  • 相关阅读:
    Goflyway
    amd 阉割理论
    wget命令下载页面里所有资源文件
    linux fpcup-Lazarus_fpcupdeluxe TEncoding 乱码
    Error: (lazbuild) 不能加载包 fpcupdeluxe 手工干预卸载问题模块
    集合 数据 指针方法操作集合
    cmake windows pthread
    4 bit all 15
    Parser b2c
    Offline Explorer 规则
  • 原文地址:https://www.cnblogs.com/anjuncc/p/5796292.html
Copyright © 2011-2022 走看看