(PECL seaslog >=1.0.0)
SeasLog::debug — 記錄除錯日誌資訊
記錄除錯日誌資訊。
注意事項:
「DEBUG」- 詳細的除錯資訊。細粒度的資訊事件。
message
日誌訊息。
content
`message` 包含佔位符,實作者會用 `content` 陣列中的值替換這些佔位符。例如 `message` 是 `log info from {NAME}` 且 `content` 是 `array('NAME' => neeke)`,則日誌資訊將會是 `log info from neeke`。
logger
如果在先前內容中呼叫了 SeasLog::setLogger() 函式,則由第三個參數指定的 `logger` 將會像一個臨時紀錄器一樣立即被使用。如果 `logger` 為 NULL 或空字串,SeasLog 將使用 SeasLog::setLogger() 所設定的最新紀錄器。
記錄日誌資訊成功時回傳 TRUE,失敗時回傳 FALSE。
範例 #1 SeasLog::debug() 範例
<?php
var_dump(SeasLog::debug('log message'));
//含內容
var_dump(SeasLog::debug('log message from {NAME}',array('NAME' => 'neeke')));
//使用臨時紀錄器
var_dump(SeasLog::debug('log message from {NAME}',array('NAME' => 'neeke'),'tmp_logger'));
var_dump(SeasLog::getBuffer());
?>
上述範例將輸出類似以下的內容:
bool(true) bool(true) bool(true) array(2) { ["/var/log/www/default/20180707.log"]=> array(2) { [0]=> string(81) "2018-07-07 11:45:49 | DEBUG | 73263 | 5b40376d1067c | 1530935149.68 | log message " [1]=> string(92) "2018-07-07 11:45:49 | DEBUG | 73263 | 5b40376d1067c | 1530935149.68 | log message from neeke " } ["/var/log/www/tmp_logger/20180707.log"]=> array(1) { [0]=> string(92) "2018-07-07 11:45:49 | DEBUG | 73263 | 5b40376d1067c | 1530935149.68 | log message from neeke " } }