Logging SQL warnings in MariaDB
If you're OK with using strict mode so that warnings are converted to errors, then you can use the MariaDB SQL Error Log Plugin to log these into a special SQL error log file:

INSTALL SONAME 'sql_errlog'; 
SHOW VARIABLES LIKE 'sql_mode';


gives:


  STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION


So we have strict mode (STRICT_TRANS_TABLES), which means this will produce an error instead of a warning (title is varchar(5)):

INSERT INTO t1 (id, title) VALUES (1, 'foobar');


Yes, we get:


  ERROR 1406 (22001): Data too long for column 'title' at row 1


... and then that error can be found in the SQL error log at /var/lib/mysql/sql_errors.log. 

(Note that the example in the question will not produce an error even in strict mode as it doesn't affect a table. As it's not an error it won't be logged to the SQL error log.)