Hi Georgi,
On 1/28/11 3:40 PM, Georgi Kodinov wrote:
> #At file:///Users/kgeorge/mysql/work/test-wl2940-trunk/ based on
> revid:jorgen.loland@stripped
>
> 3545 Georgi Kodinov 2011-01-28
> WL#2940: plugin service: error reporting
>
> Implement an my_plugin_log service.
> Added tests to the authentication plugin to return a custom
> error and a warning messages to log.
Looks good. One minor comment below.
[...]
>
> +extern "C"
> +int my_plugin_log_message(MYSQL_PLUGIN *plugin_ptr, plugin_log_level level,
> + const char *format, ...)
> +{
> + char format2[MYSQL_ERRMSG_SIZE];
> + int ret, lvl= level;
> + struct st_plugin_int *plugin = (st_plugin_int *) plugin_ptr;
> + va_list args;
> +
> + DBUG_ASSERT(lvl>= ERROR_LEVEL || lvl<= INFORMATION_LEVEL);
> +
> + if (lvl< ERROR_LEVEL || lvl> INFORMATION_LEVEL)
> + return 1;
> +
> + va_start(args, format);
> + snprintf(format2, sizeof (format2) - 1, "Plugin %.*s reported message %s",
Suggest to use something like:
"Plugin %.*s reported: '%s'"
> + (int) plugin->name.length, plugin->name.str, format);
> + ret= error_log_print((loglevel) lvl, format2, args);
It would be better to convert instead of simply casting. Something like:
switch (lvl)
case MY_ERROR_LEVEL:
level= ERROR_LEVEL;
...
default:
DBUG_ASSERT(0);
At the top of the function.
Regards,
Davi