內容簡介
透過 Amazon Simple DB 紀錄事件的外掛程式(需要Gigaom Simple DB)。
最初我們是為了在無法存取伺服器上的 PHP 錯誤日誌且無法在本機上重現錯誤時,能夠紀錄錯誤代碼,但隨著時間的推移,我們也發現它在其他幾個案例中也很實用。
以下是我們的短名單(您可能會想到更多):
需要紀錄錯誤但沒有伺服器上的錯誤日誌管理權限。
需要在兩個運行相關程式碼的不同伺服器之間記錄一個統一的日誌。
在我們的情況下,我們有兩個相互溝通的伺服器,需要一個統一的視圖來查看它們的對話。
需要紀錄罕見的錯誤,但又不想翻閱數月的錯誤日誌檔案。
使用方法
透過過濾 go_config 鉤子來設定配置資訊,當第二個過濾器屬性為go-slog時,傳回一個Amazon Simple DB憑證陣列。
array(
'aws_access_key' => 'YOUR_KEY',
'aws_secret_key' => 'YOUR_SECRET',
'aws_sdb_domain' => 'YOUR_SDB_DOMAIN',
);
SDB Domain 值類似於 SQL 資料表。它是你的日誌項目寫入的空間。如果 SDB Domain 尚不存在,Gigaom Simple DB會為您建立它。
參見Amazon Simple DB 入門指南以瞭解更多有關取得 Key 和 Secret 值的資訊。
紀錄項目:apply_filters( 'go_slog', $code, $message, $data );
$code – 一些錯誤代碼字串(例如警告、錯誤、錯誤類型1等)
$message – 一些錯誤訊息(例如嘗試聯繫端點失敗。)
$data – 在調試期間有用的數據陣列(例如:array('post_id' => 131, 'post_title' => 'Test Post'))
注意: Amazon Simple DB 值有1024位元組大小限制。
注意:我們目前沒有透過 Amazon 建議的指數退後方法來重試,因此在短時間內有太多寫入 slog 的嘗試可能會觸發 Amazon SDB 的 ServiceUnavailable 回應。 根據我們的經驗,這沒有造成太大的問題,但仍在我們需要完善的待辦事項清單上。
查看 slog:/ wp-admin / tools.php?page = go-slog-show
slog 可以分頁顯示,一次最多可以顯示 1000 項(SDB 有 1000 項查詢限制)。
slog 項目也可以匯出為 CSV。
如果您需要清除 Slog,也可以從管理面板中進行操作。
貢獻
此外掛程式是在GitHub 上進行開發。歡迎貢獻和提出問題!
外掛標籤
開發者團隊
原文外掛簡介
A way to log occurances to an Amazon Simple DB (requires Gigaom Simple DB).
We originally created this to allow us to log errors in our code when we weren’t able to access the PHP error logs on the server and weren’t able to reproduce them locally. However, since then we’ve found it useful in a few other cases as well.
Here’s our short list (you may be able to think of more):
When you need to log errors but don’t have admin access to the error logs on the server.
When you need a cosolidated log between two different servers that are running related code.
In our case we had two servers talking to each other and needed a view into how that conversation was going in a consolidated fashion.
When you have a rare error that you need to log but don’t want to dig through months of error log files.
Usage
Set config info by filtering the go_config hook and returning an array of Amazon Simple DB credentials when the second filter attribute is go-slog.
array(
'aws_access_key' => 'YOUR_KEY',
'aws_secret_key' => 'YOUR_SECRET',
'aws_sdb_domain' => 'YOUR_SDB_DOMAIN',
);
The SDB Domain value is analagous to an SQL Table. It’s the space where your log items will be written to. If the SDB Domain doesn’t exist yet Gigaom Simple DB will create it for you.
See: Amazon Simple DB Getting Started Guide for more information on getting your Key and Secret values.
Log items: apply_filters( 'go_slog', $code, $message, $data );
$code – Some error code string (e.g. warning, error, error-type-1, etc…)
$message – Some error message (e.g. Attempt to contact the endpoint failed.)
$data – An array of data that will be helpful in debugging (e.g. array( 'post_id' => 131, 'post_title' => 'Test Post' ))
Note: Amazon Simple DB values have a 1024 byte size limit.
Note: we currently have no method for doing an exponentional backoff as suggested by Amazon so too many attempts to write to the slog in a short amount of time can trigger ServiceUnavailable responses from Amazon SDB. In our experience this hasn’t been much of a problem but it’s on our to do list of things to improve.
View Slog: /wp-admin/tools.php?page=go-slog-show
Slogs can be paged through with up to 1000 items at a time (SDB has a 1000 item query limit)
Slog items can also be exported to CSV.
If you need to clear out your Slog you can do that from the admin panel as well.
Contributing
This plugin is developed and available on GitHub. Contributions and questions are welcome!
