PHP 日志包 Analog PHP

fmms 12年前發布 | 26K 次閱讀 PHP 日志處理

Analog PHP 是一個簡單的 PHP 日志包,要求 PHP 5.3+,具備可配置和可擴展性。

  • Buffer - Buffer messages to send all at once (works with Mail handler)
  • File - Append messages to a file
  • FirePHP - Send messages to FirePHP browser plugin
  • LevelBuffer - Buffer messages and send only if sufficient error level reached
  • Mail - Send email notices
  • Mongo - Save to MongoDB collection
  • Multi - Send different log levels to different handlers
  • Null - Do nothing
  • Post - Send messages over HTTP POST to another machine
  • Stderr - Send messages to STDERR
  • Syslog - Send messages to syslog
  • Variable - Buffer messages to a variable reference.

示例代碼:

<?php

require_once ('Analog.php');

// Default logging to /tmp/analog.txt
Analog::log ('Log this error');

// Log to a MongoDB log collection
Analog::handler (function ($info) {
    static $conn = null;
    if (! $conn) {
        $conn = new Mongo ('localhost:27017');
    }
    $conn->mydb->log->insert ($info);
});

// Log an alert
Analog::log ('The sky is falling!', Analog::ALERT);

// Log some debug info
Analog::log ('Debugging info', Analog::DEBUG);

?>

項目主頁:http://www.baiduhome.net/lib/view/home/1326163963015

 本文由用戶 fmms 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!