- Timestamp:
- 05/30/2016 06:15:50 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/0-logger.php
r3156 r3273 25 25 $data = (array) $data; 26 26 redact_keys( $data ); 27 $data = str_replace( "\n", '[newline]', serialize( $data ) );27 $data = str_replace( "\n", '[newline]', wp_json_encode( $data ) ); 28 28 } 29 29 … … 34 34 $backtrace[1]['function'], 35 35 $error_code, 36 $data ? ' - ' . $data : ''36 $data ? ' -- ' . $data : '' 37 37 ); 38 38 … … 67 67 return $data; 68 68 } 69 70 /** 71 * Format entries created with log() 72 * 73 * See WordCamp_CLI_Miscellaneous::format_log() for usage instructions. 74 * 75 * @param string $raw_log 76 * @param string $foreign_entries `ignore` or `include` entries that weren't created with log() 77 * 78 * @return string 79 */ 80 function format_log( $raw_log, $foreign_entries = 'include' ) { 81 $formatted_log = ''; 82 $raw_entries = explode( "\n", $raw_log ); 83 $native_entry_pattern = '/(\[.*?\]) (.*?:.*?) - (.*?) -- (\{.*\})/'; 84 85 foreach ( $raw_entries as $entry ) { 86 $is_native_entry = 1 === preg_match( $native_entry_pattern, $entry, $entry_parts ); 87 88 if ( $is_native_entry ) { 89 $formatted_log .= sprintf( 90 "\n%s %s - %s\n%s", 91 $entry_parts[1], 92 $entry_parts[2], 93 $entry_parts[3], 94 print_r( json_decode( $entry_parts[4] ), true ) 95 ); 96 } else { 97 if ( 'ignore' !== $foreign_entries ) { 98 $formatted_log .= $entry . "\n"; 99 } 100 } 101 } 102 103 return $formatted_log; 104 }
Note: See TracChangeset
for help on using the changeset viewer.