/** * ログの出力を行う * * エラー・警告は trigger_error() を経由して利用すること。(補足の出力は例外。) * @param string $msg * @param string $path * @param bool $verbose 冗長な出力を行うか */ function gfPrintLog($msg, $path = '', $verbose = USE_VERBOSE_LOG) { // 日付の取得 $today = date('Y/m/d H:i:s'); // 出力パスの作成 if (strlen($path) === 0) { $path = GC_Utils_Ex::isAdminFunction() ? ADMIN_LOG_REALFILE : LOG_REALFILE; } $msg = "{$today} [{$_SERVER['SCRIPT_NAME']}] {$msg} from {$_SERVER['REMOTE_ADDR']}\n"; if ($verbose) { if (GC_Utils_Ex::isFrontFunction()) { $msg .= 'customer_id = ' . $_SESSION['customer']['customer_id'] . "\n"; } if (GC_Utils_Ex::isAdminFunction()) { $msg .= 'login_id = ' . $_SESSION['login_id'] . '(' . $_SESSION['authority'] . ')' . '[' . session_id() . ']' . "\n"; } $msg .= GC_Utils_Ex::toStringBacktrace(GC_Utils_Ex::getDebugBacktrace()); } error_log($msg, 3, $path); // ログテーション GC_Utils_Ex::gfLogRotation(MAX_LOG_QUANTITY, MAX_LOG_SIZE, $path); }
function gfPrintLog($mess, $path = '') { // 日付の取得 $today = date("Y/m/d H:i:s"); // 出力パスの作成 if ($path == "") { $path = LOG_REALFILE; } // エスケープされている文字をもとに戻す $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); $mess = strtr($mess, $trans_tbl); $fp = fopen($path, "a+"); if ($fp) { fwrite($fp, $today . " [" . $_SERVER['PHP_SELF'] . "] " . $mess . " from " . $_SERVER['REMOTE_ADDR'] . "\n"); fclose($fp); } // ログテーション GC_Utils_Ex::gfLogRotation(MAX_LOG_QUANTITY, MAX_LOG_SIZE, $path); }