Skip to content

Commit

Permalink
Update Debug.php
Browse files Browse the repository at this point in the history
  • Loading branch information
luizbills authored May 24, 2022
1 parent 3b658c6 commit e0281ac
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions core/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static function throw_if ( $condition, $message, $error_code = -1, $excep
if ( \is_callable( $message ) ) {
$message = $message();
}
if ( ! $exception_class || ! \class_exists( $exception_class ) ) {
if ( ! $exception_class ) {
$exception_class = \RuntimeException::class;
}
throw new $exception_class( $message, (int) $error_code );
Expand All @@ -21,25 +21,25 @@ public static function log () {
if ( ! defined( 'WP_DEBUG_LOG' ) || ! WP_DEBUG_LOG ) return;
$output = [];
foreach ( \func_get_args() as $arg ) {
$value = '';
if ( \is_object( $arg ) || \is_array( $arg ) ) {
$value = \print_r( $arg, true );
}
elseif ( \is_bool( $arg ) ) {
$value = $arg ? 'bool(true)' : 'bool(false)';
}
elseif ( '' === $arg ) {
$value = 'empty_string';
}
elseif ( null === $arg ) {
$value = 'NULL';
}
else {
$value = $arg;
}
$output[] = $value;
$output[] = self::format( $arg );
}
$slug = Config::get( 'SLUG' );
\error_log( "[$slug] " . \implode( ' ', $output ) );
}

public static function format ( $value ) {
if ( \is_object( $value ) || \is_array( $value ) ) {
$value = \print_r( $value, true );
}
elseif ( \is_bool( $arg ) ) {
$value = $value ? 'BOOL(TRUE)' : 'BOOL(FALSE)';
}
elseif ( '' === $value ) {
$value = 'EMPTY_STRING';
}
elseif ( null === $value ) {
$value = 'NULL';
}
return $value;
}
}

0 comments on commit e0281ac

Please sign in to comment.