Created
December 25, 2012 06:17
-
-
Save vexus2/4371866 to your computer and use it in GitHub Desktop.
PHP error_log拡張メソッド
呼び出しファイルやメソッド名を出力
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 標準のerror_logメソッドを拡張し、呼び出し箇所の行数等を追加表示させる | |
| * | |
| * @param $message | |
| * @param null $message_type | |
| * @param null $destination | |
| * @param null $extra_headers | |
| */ | |
| function e_log ($id, $message, $level = LEVEL_ERR , $message_type = null, $destination = null, $extra_headers = null ) { | |
| error_log('---------------------------'); | |
| $backtraces = debug_backtrace(); | |
| $func_name = $backtraces[1]['function']; | |
| $class_name = $backtraces[1]['class']; | |
| $line = $backtraces[0]['line']; | |
| error_log("[{$level}] $class_name#$func_name. line: $line"); | |
| //Cake標準や外部(Log4php)ログを使用すると複数サーバにログが散ってしまうため、エラーログで代用する | |
| error_log( "[${id}] " . $message, $message_type, $destination, $extra_headers ); | |
| error_log('---------------------------'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment