メインコンテンツまでスキップ
Version: Fegg 5.x

Log::errorとほかのレベル

指定のレベルで1件書き込みます

説明​

public static bool Log::debug( string $message [, array $context = array() ] )
public static bool Log::info( string $message [, array $context = array() ] )
public static bool Log::notice( string $message [, array $context = array() ] )
public static bool Log::warning( string $message [, array $context = array() ] )
public static bool Log::error( string $message [, array $context = array() ] )
public static bool Log::critical( string $message [, array $context = array() ] )
public static bool Log::alert( string $message [, array $context = array() ] )
public static bool Log::emergency( string $message [, array $context = array() ] )

関数名と同じレベルで1行書き込みます(レベルを参照)。書き込めたらtrueを返します。$settings['log_level']より低いレベルのときや、書き込めなかったとき(PHPのエラーログに書き込みます)はfalseを返します。

引数​

名前データ型デフォルト備考
$messagestringメッセージ。{key}は$context['key']に置き換わります
$contextarrayarray()JSONにして行に追加する値。例外は'exception'に入れます

例​

Controller
use Fegg\Log;

Log::info('{count} entries imported from {file}', array('count' => $count, 'file' => $name));

try {
$mail->send($to);
} catch (\Exception $e) {
Log::error('Mail not sent to {to}', array('to' => $to, 'exception' => $e));
$this->page['error'] = true;
}
site/data/log/fegg-2026-11-14.log
[2026-11-14 10:12:30 +09:00] INFO 120 entries imported from news.csv {"count":120,"file":"news.csv"} | POST /cms/import/ 203.0.113.5