@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | protected function interpolate( $message, array $context = [] ) |
| 153 | 153 | { |
| 154 | - if( is_array( $message )) { |
|
| 154 | + if( is_array( $message ) ) { |
|
| 155 | 155 | return htmlspecialchars( print_r( $message, true ), ENT_QUOTES, 'UTF-8' ); |
| 156 | 156 | } |
| 157 | 157 | $replace = []; |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | if( is_object( $val ) && get_class( $val ) === 'DateTime' ) { |
| 160 | 160 | $val = $val->format( 'Y-m-d H:i:s' ); |
| 161 | 161 | } |
| 162 | - else if( is_object( $val ) || is_array( $val )) { |
|
| 162 | + else if( is_object( $val ) || is_array( $val ) ) { |
|
| 163 | 163 | $val = json_encode( $val ); |
| 164 | 164 | } |
| 165 | - else if( is_resource( $val )) { |
|
| 165 | + else if( is_resource( $val ) ) { |
|
| 166 | 166 | $val = (string) $val; |
| 167 | 167 | } |
| 168 | 168 | $replace['{'.$key.'}'] = $val; |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | protected function log( $level, $message, array $context = [] ) |
| 180 | 180 | { |
| 181 | - if( !in_array( $level, (new ReflectionClass( __NAMESPACE__.'\Log' ))->getConstants(), true ) |
|
| 181 | + if( !in_array( $level, ( new ReflectionClass( __NAMESPACE__.'\Log' ) )->getConstants(), true ) |
|
| 182 | 182 | || !Development::isDev() |
| 183 | 183 | )return; |
| 184 | - $date = get_date_from_gmt( gmdate('Y-m-d H:i:s') ); |
|
| 184 | + $date = get_date_from_gmt( gmdate( 'Y-m-d H:i:s' ) ); |
|
| 185 | 185 | $level = strtoupper( $level ); |
| 186 | 186 | $message = $this->interpolate( $message, $context ); |
| 187 | - $entry = "[$date] $level: $message" . PHP_EOL; |
|
| 188 | - file_put_contents( $this->file, $entry, FILE_APPEND|LOCK_EX ); |
|
| 187 | + $entry = "[$date] $level: $message".PHP_EOL; |
|
| 188 | + file_put_contents( $this->file, $entry, FILE_APPEND | LOCK_EX ); |
|
| 189 | 189 | } |
| 190 | 190 | } |
@@ -5,8 +5,7 @@ discard block |
||
| 5 | 5 | use GeminiLabs\Castor\Facades\Development; |
| 6 | 6 | use ReflectionClass; |
| 7 | 7 | |
| 8 | -class Log |
|
| 9 | -{ |
|
| 8 | +class Log { |
|
| 10 | 9 | const EMERGENCY = 'emergency'; |
| 11 | 10 | const ALERT = 'alert'; |
| 12 | 11 | const CRITICAL = 'critical'; |
@@ -180,7 +179,9 @@ discard block |
||
| 180 | 179 | { |
| 181 | 180 | if( !in_array( $level, (new ReflectionClass( __NAMESPACE__.'\Log' ))->getConstants(), true ) |
| 182 | 181 | || !Development::isDev() |
| 183 | - )return; |
|
| 182 | + ) { |
|
| 183 | + return; |
|
| 184 | + } |
|
| 184 | 185 | $date = get_date_from_gmt( gmdate('Y-m-d H:i:s') ); |
| 185 | 186 | $level = strtoupper( $level ); |
| 186 | 187 | $message = $this->interpolate( $message, $context ); |