Skip to content

Commit a9dccbf

Browse files
authored
Add format attribute on logging functions (#47)
Prevents using the wrong format specifier.
1 parent 1cacf6b commit a9dccbf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

include/aws/logging/logging.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum class verbosity {
2727

2828
void log(verbosity v, char const* tag, char const* msg, va_list args);
2929

30-
static inline void log_error(char const* tag, char const* msg, ...)
30+
[[gnu::format(printf, 2, 3)]] static inline void log_error(char const* tag, char const* msg, ...)
3131
{
3232
va_list args;
3333
va_start(args, msg);
@@ -37,7 +37,7 @@ static inline void log_error(char const* tag, char const* msg, ...)
3737
(void)msg;
3838
}
3939

40-
static inline void log_info(char const* tag, char const* msg, ...)
40+
[[gnu::format(printf, 2, 3)]] static inline void log_info(char const* tag, char const* msg, ...)
4141
{
4242
#if AWS_LAMBDA_LOG >= 1
4343
va_list args;
@@ -50,7 +50,7 @@ static inline void log_info(char const* tag, char const* msg, ...)
5050
#endif
5151
}
5252

53-
static inline void log_debug(char const* tag, char const* msg, ...)
53+
[[gnu::format(printf, 2, 3)]] static inline void log_debug(char const* tag, char const* msg, ...)
5454
{
5555
#if AWS_LAMBDA_LOG >= 2
5656
va_list args;

0 commit comments

Comments
 (0)