Changeset 31102 for trunk/i.php
- Timestamp:
- Apr 24, 2015, 4:00:50 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/i.php
r28587 r31102 31 31 @include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR .'config/database.inc.php'); 32 32 33 include(PHPWG_ROOT_PATH . 'include/Logger.class.php'); 34 35 $logger = new Logger(array( 36 'directory' => PHPWG_ROOT_PATH . $conf['data_location'] . $conf['log_dir'], 37 'severity' => $conf['log_level'], 38 // we use an hashed filename to prevent direct file access, and we salt with 39 // the db_password instead of secret_key because the log must be usable in i.php 40 // (secret_key is in the database) 41 'filename' => 'log_' . date('Y-m-d') . '_' . sha1(date('Y-m-d') . $conf['db_password']) . '.txt', 42 )); 43 33 44 34 45 function trigger_notify() {} … … 67 78 // end fast bootstrap 68 79 69 function ilog()70 {71 global $conf;72 if (!$conf['enable_i_log']) return;73 74 $line = date("c");75 foreach( func_get_args() as $arg)76 {77 $line .= ' ';78 if (is_array($arg))79 {80 $line .= implode(' ', $arg);81 }82 else83 {84 $line .= $arg;85 }86 }87 $file=PHPWG_ROOT_PATH.$conf['data_location'].'tmp/i.log';88 if (false == file_put_contents($file, $line."\n", FILE_APPEND))89 {90 mkgetdir(dirname($file));91 }92 }93 94 80 function ierror($msg, $code) 95 81 { 82 global $logger; 96 83 if ($code==301 || $code==302) 97 84 { … … 102 89 // default url is on html format 103 90 $url = html_entity_decode($msg); 91 $logger->warning($code . ' ' . $url, 'i.php', array( 92 'url' => $_SERVER['REQUEST_URI'], 93 )); 104 94 header('Request-URI: '.$url); 105 95 header('Content-Location: '.$url); 106 96 header('Location: '.$url); 107 ilog('WARN', $code, $url, $_SERVER['REQUEST_URI']);108 97 exit; 109 98 } … … 118 107 //todo improve 119 108 echo $msg; 120 ilog('ERROR', $code, $msg, $_SERVER['REQUEST_URI']); 109 $logger->error($code . ' ' . $msg, 'i.php', array( 110 'url' => $_SERVER['REQUEST_URI'], 111 )); 121 112 exit; 122 113 } … … 405 396 catch (Exception $e) 406 397 { 407 ilog("db error", $e->getMessage());398 $logger->error($e->getMessage(), 'i.php'); 408 399 } 409 400 pwg_db_check_charset(); … … 502 493 catch (Exception $e) 503 494 { 504 ilog("db error", $e->getMessage());495 $logger->error($e->getMessage(), 'i.php'); 505 496 } 506 497 } … … 622 613 $timing['send'] = time_step($step); 623 614 624 ilog('perf', 625 basename($page['src_path']), $o_size, $o_size[0]*$o_size[1], 626 basename($page['derivative_path']), $d_size, $d_size[0]*$d_size[1], 627 function_exists('memory_get_peak_usage') ? round( memory_get_peak_usage()/(1024*1024), 1) : '', 628 time_step($begin), 629 '|', $timing); 630 ?> 615 $timing['total'] = time_step($begin); 616 617 if ($logger->severity() >= Logger::INFO) 618 { 619 $logger->info('perf', 'i.php', array( 620 'src_path' => basename($page['src_path']), 621 'derivative_path' => basename($page['derivative_path']), 622 'o_size' => $o_size[0] . ' ' . $o_size[1] . ' ' . ($o_size[0]*$o_size[1]), 623 'd_size' => $d_size[0] . ' ' . $d_size[1] . ' ' . ($d_size[0]*$d_size[1]), 624 'mem_usage' => function_exists('memory_get_peak_usage') ? round( memory_get_peak_usage()/(1024*1024), 1) : '', 625 'timing' => $timing, 626 )); 627 }
Note: See TracChangeset
for help on using the changeset viewer.