Skip to content

Commit 28fc58e

Browse files
committed
Add WsLog::w to log warning messages
1 parent 695e0f8 commit 28fc58e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/WsLog.php

+20
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ public static function l( string $text ) : void {
4242
}
4343
}
4444

45+
public static function w( string $text ) : void {
46+
global $wpdb;
47+
48+
$table_name = $wpdb->prefix . 'wp2static_log';
49+
50+
$wpdb->insert(
51+
$table_name,
52+
[
53+
'log' => $text,
54+
]
55+
);
56+
57+
if ( defined( 'WP_CLI' ) ) {
58+
$date = current_time( 'c' );
59+
\WP_CLI::warning(
60+
\WP_CLI::colorize( "%W[$date] %n$text" )
61+
);
62+
}
63+
}
64+
4565
/**
4666
* Log multiple lines at once
4767
*

0 commit comments

Comments
 (0)