http://qiita.com/qiita-kurara/items/28e0db3b852867aceab9
public static function infoLog($input=null,$output=null){ $monolog = \Log::getMonolog(); $in['test']="test"; $monolog->pushProcessor(function ($record) { $record['extra']['input'] = $in; return $record; }); $monolog->pushProcessor(new \Monolog\Processor\MemoryUsageProcessor()); $monolog->info('Usage Memory'); }
laravelで上記のサイトを参考に上のようにログに配列をまとめて渡したいのですがエラーになってしまいます
想定している出力としては
local.INFO: Usage Memory {"input":{"test":"test"}}
みたいに想定しているのですが、うまくやるほうほうはないでしょうか
「エラーになってしまいます。」のエラーはどの様なメッセージが出ているのでしょうか?
PHP Fatal error: Uncaught exception 'ErrorException' with message 'Undefined variable: in' in C:\\develop\\project\\project1\\app\\Libs\\CommonLog.php:22\nStack trace:\n#0 C:\\develop\\project\\project1\\app\\Libs\\CommonLog.php(22): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'Undefined varia...', 'C:\\\\develop\\\\proj...', 22, Array)\n#1 [internal function]: app\\Libs\\CommonLog::app\\Libs\\{closure}(Array)\n#2 C:\\develop\\project\\project1\\bootstrap\\cache\\compiled.php(13117): call_user_func(Object(Closure), Array)\n#3 C:\\develop\\project\\project1\\bootstrap\\cache\\compiled.php(13218): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#4 C:\\develop\\project\\project1\\bootstrap\\cache\\compiled.php(12913): Monolog\\Logger->error(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#5 C:\\develop\\project\\project1\\bootstrap\\cache\\compiled.php(12884): Illuminate\\Log\\Writer->writeLog('error', Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#6 C:\\develop\\project\\project1\\vend in C:\\develop\\project\\project1\\app\\Libs\\CommonLog.php on line 22
22行目は$record['extra']['input'] = $in;の部分になります