Skip to content

Commit 302caa9

Browse files
ParadoxV5vuvova
authored andcommitted
Tag the logger service with ATTRIBUTE_FORMAT
[Breaking] The `logger` service passes formats and args directly to `my_vsnprintf`. Just like the `my_snprintf` service, I increased this service’s major version because: * Custom suffixes are now a thing (and custom specifiers will soon no longer be). * GCC `-Wformat` now checks formats sent to them.
1 parent 2392bd0 commit 302caa9

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

include/mysql/service_logger.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef MYSQL_ABI_CHECK
2020
#include <stdarg.h>
2121
#endif
22+
#include <my_attribute.h>
2223

2324
/**
2425
@file
@@ -65,8 +66,10 @@ extern struct logger_service_st {
6566
unsigned long long size_limit,
6667
unsigned int rotations);
6768
int (*close)(LOGGER_HANDLE *log);
68-
int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
69-
int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...);
69+
int (*vprintf)(LOGGER_HANDLE *log, const char *fmt, va_list argptr)
70+
ATTRIBUTE_FORMAT_FPTR(printf, 2, 0);
71+
int (*printf)(LOGGER_HANDLE *log, const char *fmt, ...)
72+
ATTRIBUTE_FORMAT_FPTR(printf, 2, 3);
7073
int (*write)(LOGGER_HANDLE *log, const char *buffer, size_t size);
7174
int (*rotate)(LOGGER_HANDLE *log);
7275
} *logger_service;
@@ -90,8 +93,10 @@ extern struct logger_service_st {
9093
unsigned long long size_limit,
9194
unsigned int rotations);
9295
int logger_close(LOGGER_HANDLE *log);
93-
int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr);
94-
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...);
96+
int logger_vprintf(LOGGER_HANDLE *log, const char *fmt, va_list argptr)
97+
ATTRIBUTE_FORMAT(printf, 2, 0);
98+
int logger_printf(LOGGER_HANDLE *log, const char *fmt, ...)
99+
ATTRIBUTE_FORMAT(printf, 2, 3);
95100
int logger_write(LOGGER_HANDLE *log, const char *buffer, size_t size);
96101
int logger_rotate(LOGGER_HANDLE *log);
97102
#endif

include/service_versions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#define VERSION_base64 0x0100
2727
#define VERSION_encryption 0x0300
2828
#define VERSION_encryption_scheme 0x0100
29-
#define VERSION_logger 0x0100
29+
#define VERSION_logger 0x0200
3030
#define VERSION_my_crypt 0x0100
3131
#define VERSION_my_md5 0x0100
3232
#define VERSION_my_print_error 0x0200

plugin/sql_errlog/sql_errlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void log_sql_errors(MYSQL_THD thd __attribute__((unused)),
118118
if (event->database.str)
119119
{
120120
logger_printf(logfile, "%04d-%02d-%02d %2d:%02d:%02d %lu "
121-
"%s %`s %s %d: %s : %s \n",
121+
"%s %sQ %s %d: %s : %s \n",
122122
t.tm_year + 1900, t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min,
123123
t.tm_sec, event->general_thread_id, event->general_user,
124124
event->database.str, type,

0 commit comments

Comments
 (0)