Logger: Annotate logPrint with format attribute

This allows the compiler to check for mismatches in the format string and the passed parameters.
This commit is contained in:
Peter Keresztes Schmidt 2021-04-29 00:11:24 +02:00
parent 0da4127114
commit c3dd8d8a47
2 changed files with 8 additions and 3 deletions

View File

@ -415,7 +415,7 @@ void Logger::closeSyslog() {
(void) closelog();
}
void Logger::logPrint(bool hex, const char * const filepath, const int line, const int level, const char *fstring, ...) {
void Logger::logPrint(bool hex, const char *filepath, int line, int level, const char *fstring, ...) {
if (level > mEffectiveLevel) return;
if (level < PANIC || level > DEBUG9)
Panic("Invalid logger level %d", level);

View File

@ -174,7 +174,12 @@ private:
void closeDatabase();
public:
void logPrint(bool hex, const char * const filepath, const int line, const int level, const char *fstring, ...);
void logPrint(bool hex,
const char *filepath,
int line,
int level,
const char *fstring,
...) __attribute__((format(printf, 6, 7)));
};
void logInit(const char *name, const Logger::Options &options=Logger::Options());