[WordPress] 外掛分享: WP MyLogger

WordPress 外掛 WP MyLogger 的封面圖片。

前言介紹

  • 這款 WordPress 外掛「WP MyLogger」是 2015-03-12 上架。 目前已經下架不再更新,不建議安裝使用。
  • 目前有 10 個安裝啟用數。
  • 上一次更新是 2015-03-16,距離現在已有 3702 天。超過一年沒更新,安裝要確認版本是否可用。以及後續維護問題!
  • 外掛最低要求 WordPress 3.5.1 以上版本才可以安裝。
  • 尚未有人給過這款外掛評分。
  • 還沒有人在論壇上發問,可能目前使用數不多,還沒有什麼大問題。

外掛協作開發者

paniko |

外掛標籤

debug | logger | appenders | developer |

內容簡介

若要使用自定義的附加器,請在你的初始外掛中加入以下程式碼(以LoggerAppenderDailyFile、LoggerAppenderRollingFile、LoggerAppenderFile、LoggerAppenderMail、LoggerAppenderMailEvent等附加器為選項),對於每一種類型,你必須具體指定相關的參數,參考log4php的官方文件。

針對滾動檔案附加器:

$parameters = array(
'fileName' => __DIR__.'/logs/debug.log',
'fileAppend' => true,
'maxSize' => '1MB',
My_Logger::ROLLING_APPENDER => true,
My_Logger::ROLLING_MAX_BACKUP_INDEX => 5
);
$mylogger = My_Logger::get_instance('', My_Logger::ROLLING, $parameters);
$this->logger = $mylogger->getLogger();
// 增加測試輸出:
$this->logger->debug($parameters);
$this->logger->debug('test');

針對郵件附加器:

$parameters = array(
'smtpHost' => '',
'smtpUsername' => '',
'smtpPassword' => '',
'from' => '',
My_Logger::MAIL_TO => '',
My_Logger::MAIL_SUBJECT => '',
My_Logger::THRESHOLD => My_Logger::LEVEL_DEBUG
);
$mylogger = My_Logger::get_instance('', My_Logger::MAIL, $parameters);

** 設定Logger的閥值 ** 閥值用來描述輸出訊息的嚴重性,共有六個級別,按降序排序如下。你可以透過加入下列參數來設定Logger的閥值:

FATAL:最嚴重的錯誤事件,應用程式會因此中止。
ERROR:尚可容忍的錯誤事件,應用程式可以繼續執行。
WARN:可疑事件,應用程式可以繼續執行。
INFO:粗略的應用程式進展訊息。
DEBUG:適用於除錯的詳細應用程式進展事件。
TRACE:最詳細的應用程式進展訊息。

若想要在前端放置Logger,請在模板Script中加入以下程式碼:

$parameters = array(
'fileName' => __DIR__.'/logs/debug.log',
'fileAppend' => true,
'maxSize' => '1MB',
My_Logger::ROLLING_APPENDER => true,
My_Logger::ROLLING_MAX_BACKUP_INDEX => 5,
My_Logger::THRESHOLD => My_Logger::LEVEL_DEBUG
);
$mylogger = new My_Logger('', My_Logger::ROLLING, $parameters);
$logger = $mylogger->getLogger();
$logger->debug('test my logger');

詳細資訊可參閱log4php的API文件:Apache Log4php Docs

** 設定 ** 你可以在外掛的設定中設定其配置檔案的路徑,以導出Logger

原文外掛簡介

To use the custom appenders, add this code in your init plugin for example: Choose among appenders (LoggerAppenderDailyFile, LoggerAppenderRollingFile, LoggerAppenderFile, LoggerAppenderMail, LoggerAppenderMailEvent), for each type you must
specify the relative parameters, how to official documentation of log4php.

For rolling file appenders:
‘1MB’, My_Logger::ROLLING_APPENDER => true, My_Logger::ROLLING_MAX_BACKUP_INDEX => 5 ); $mylogger = My_Logger::get_instance(“”, My_Logger::ROLLING, $parameters); $this->logger = $mylogger->getLogger(); //for debug you add: $this->logger->debug($parameters); $this->logger->debug(“test”); ?>

For mail appender: ”, My_Logger::MAIL_TO => ”, My_Logger::MAIL_SUBJECT => ”, My_Logger::THRESHOLD => My_Logger::LEVEL_DEBUG//6: Sets the root logger level to DEBUG. This means that logging requests with the level lower than DEBUG will not be logged by the root logger. );
$mylogger = My_Logger::get_instance(“”, My_Logger::MAIL, $parameters); ?>

** SET Logger threshold ** A level describes the severity of a logging message. There are six levels, show here in descending order of severity. You can set level of logger, add the parameter:

FATAL Highest Very severe error events that will presumably lead the application to abort.
ERROR … Error events that might still allow the application to continue running.
WARN … Potentially harmful situations which still allow the application to continue running.
INFO … Informational messages that highlight the progress of the application at coarse-grained level.
DEBUG … Fine-grained informational events that are most useful to debug an application.
TRACE Lowest Finest-grained informational events.

If do you want put a logger in frontend, add this code in template script: ‘1MB’, My_Logger::ROLLING_APPENDER => true, My_Logger::ROLLING_MAX_BACKUP_INDEX => 5, My_Logger::THRESHOLD => My_Logger::LEVEL_DEBUG );
$mylogger = new My_Logger(“”, My_Logger::ROLLING, $parameters);
$logger = $mylogger->getLogger(); $logger->debug(“test my logger”); ?>
For more info read the API documents of log4php:Apache Log4php Docs
** Configuration ** You can set configuration path file to export your logger, in the plugin’s settings.

各版本下載點

  • 方法一:點下方版本號的連結下載 ZIP 檔案後,登入網站後台左側選單「外掛」的「安裝外掛」,然後選擇上方的「上傳外掛」,把下載回去的 ZIP 外掛打包檔案上傳上去安裝與啟用。
  • 方法二:透過「安裝外掛」的畫面右方搜尋功能,搜尋外掛名稱「WP MyLogger」來進行安裝。

(建議使用方法二,確保安裝的版本符合當前運作的 WordPress 環境。


最新版本

延伸相關外掛(你可能也想知道)

暫無相關外掛推薦。

文章
Filter
Apply Filters
Mastodon