- Timestamp:
- 05/31/2016 11:40:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/0-logger.php
r3273 r3284 29 29 30 30 $log_entry = sprintf( 31 '%s:%s - %s:%s%s', 31 '[%s] %s:%s - %s:%s%s', 32 get_unique_request_id(), 32 33 basename( $backtrace[0]['file'] ), 33 34 $backtrace[0]['line'], … … 69 70 70 71 /** 72 * Generate a unique ID for the current request 73 * 74 * This is useful when debugging race conditions, etc, so that you can identify which log entries belong to each thread. 75 * 76 * Based on https://stackoverflow.com/a/22508709/450127 77 * 78 * @return string 79 */ 80 function get_unique_request_id() { 81 return hash( 'crc32b', $_SERVER['REMOTE_ADDR'] . $_SERVER['REMOTE_PORT'] . $_SERVER['REQUEST_TIME_FLOAT'] ); 82 } 83 84 /** 71 85 * Format entries created with log() 72 86 * … … 81 95 $formatted_log = ''; 82 96 $raw_entries = explode( "\n", $raw_log ); 83 $native_entry_pattern = '/(\[.*?\]) ( .*?:.*?) - (.*?) -- (\{.*\})/';97 $native_entry_pattern = '/(\[.*?\]) (\[\w+\]) (.*?:.*?) - (.*?) -- (\{.*\})/'; 84 98 85 99 foreach ( $raw_entries as $entry ) { … … 88 102 if ( $is_native_entry ) { 89 103 $formatted_log .= sprintf( 90 "\n%s %s - %s\n%s",104 "\n%s %s %s - %s\n%s", 91 105 $entry_parts[1], 92 106 $entry_parts[2], 93 107 $entry_parts[3], 94 print_r( json_decode( $entry_parts[4] ), true ) 108 $entry_parts[4], 109 print_r( json_decode( $entry_parts[5] ), true ) 95 110 ); 96 111 } else {
Note: See TracChangeset
for help on using the changeset viewer.