Changeset 1239660
- Timestamp:
- 09/07/2015 10:37:38 AM (11 years ago)
- Location:
- stream-to-papertrail
- Files:
-
- 7 added
- 7 edited
-
assets/banner-1544x500.png (modified) (1 prop) (previous)
-
assets/banner-772x250.png (modified) (1 prop) (previous)
-
assets/icon-128x128.png (modified) (1 prop) (previous)
-
assets/icon-256x256.png (modified) (1 prop) (previous)
-
tags/0.0.4 (added)
-
tags/0.0.4/inc (added)
-
tags/0.0.4/inc/class-stream-papertrail-api.php (added)
-
tags/0.0.4/readme.md (added)
-
tags/0.0.4/readme.txt (added)
-
tags/0.0.4/stream-papertrail.php (added)
-
trunk/inc/class-stream-papertrail-api.php (modified) (2 diffs)
-
trunk/readme.md (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/stream-papertrail.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
stream-to-papertrail/assets/banner-1544x500.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
stream-to-papertrail/assets/banner-772x250.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
stream-to-papertrail/assets/icon-128x128.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
stream-to-papertrail/assets/icon-256x256.png
-
Property
svn:mime-type
changed from
application/octet-streamtoimage/png
-
Property
svn:mime-type
changed from
-
stream-to-papertrail/trunk/inc/class-stream-papertrail-api.php
r1239401 r1239660 51 51 'default' => 'stream', 52 52 ), 53 array( 54 'name' => 'enable_colorization', 55 'title' => esc_html__( 'Colorization', 'stream-papertrail' ), 56 'type' => 'checkbox', 57 'desc' => esc_html__( '', 'stream-papertrail' ), 58 'after_field' => esc_html__( 'Enabled', 'stream-papertrail' ), 59 'default' => 1, 60 ), 53 61 ), 54 62 ); … … 85 93 $component = $this->options['papertrail_component']; 86 94 87 $syslog_message = '<22>' . date( 'M d H:i:s ' ) . $program . ' ' . $component . ': ' . $ message;95 $syslog_message = '<22>' . date( 'M d H:i:s ' ) . $program . ' ' . $component . ': ' . $this->format( $message ); 88 96 89 97 $sock = socket_create( AF_INET, SOCK_DGRAM, SOL_UDP ); 90 98 socket_sendto( $sock, $syslog_message, strlen( $syslog_message ), 0, $destination['hostname'], $destination['port'] ); 91 99 socket_close( $sock ); 100 101 } 102 103 public function format( $message ) { 104 105 if ( ! empty( $this->options['papertrail_enable_colorization'] ) && $this->options['papertrail_enable_colorization'] === 1 ) { 106 $message = $this->colorise_json( $message ); 107 } 108 return $message; 109 110 } 111 112 public function colorise_json( $json ) { 113 114 $seq = array( 115 'reset' => "\033[0m", 116 'color' => "\033[1;%dm", 117 'bold' => "\033[1m", 118 ); 119 120 $fcolor = array( 121 'black' => "\033[30m", 122 'red' => "\033[31m", 123 'green' => "\033[32m", 124 'yellow' => "\033[33m", 125 'blue' => "\033[34m", 126 'magenta' => "\033[35m", 127 'cyan' => "\033[36m", 128 'white' => "\033[37m", 129 ); 130 131 $bcolor = array( 132 'black' => "\033[40m", 133 'red' => "\033[41m", 134 'green' => "\033[42m", 135 'yellow' => "\033[43m", 136 'blue' => "\033[44m", 137 'magenta' => "\033[45m", 138 'cyan' => "\033[46m", 139 'white' => "\033[47m", 140 ); 141 142 $output = $json; 143 $output = preg_replace( '/(":)([0-9]+)/', '$1' . $fcolor['magenta'] . '$2' . $seq['reset'], $output ); 144 $output = preg_replace( '/(":)(true|false)/', '$1' . $fcolor['magenta'] . '$2' . $seq['reset'], $output ); 145 $output = str_replace( '{"', '{' . $fcolor['green'] . '"', $output ); 146 $output = str_replace( ',"', ',' . $fcolor['green'] . '"', $output ); 147 $output = str_replace( '":', '"' . $seq['reset'] . ':', $output ); 148 $output = str_replace( ':"', ':' . $fcolor['green'] . '"', $output ); 149 $output = str_replace( '",', '"' . $seq['reset'] . ',', $output ); 150 $output = str_replace( '",', '"' . $seq['reset'] . ',', $output ); 151 $output = $seq['reset'] . $output . $seq['reset']; 152 153 return $output; 92 154 93 155 } -
stream-to-papertrail/trunk/readme.txt
r1239403 r1239660 4 4 Requires at least: 4.3 5 5 Tested up to: 4.3 6 Stable tag: 0.0. 36 Stable tag: 0.0.4 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 21 21 22 22 == Changelog == 23 24 = 0.0.4 - September 7, 2015 = 25 26 * Added option to enable/disable colourisation 27 28 Props [@Japh](https://github.com/japh) 23 29 24 30 = 0.0.3 - September 7, 2015 = -
stream-to-papertrail/trunk/stream-papertrail.php
r1239401 r1239660 5 5 * Description: Send Stream logs to Papertrail for safe-keeping. 6 6 * Author: Japh 7 * Version: 0.0. 37 * Version: 0.0.4 8 8 * Author URI: http://japh.com.au/ 9 9 */
Note: See TracChangeset
for help on using the changeset viewer.