Apply clang format to files

Also add brackets for all scopes at the same time
This commit is contained in:
Marc Di Luzio
2018-01-15 12:22:25 +00:00
parent ee1c51d0b0
commit 2bbaab129b
15 changed files with 378 additions and 357 deletions

View File

@@ -32,28 +32,50 @@ POSSIBILITY OF SUCH DAMAGE.
#define _LOGGING_GAMEMODE_H_
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <stdbool.h>
// Logging helpers
#define PLOG_MSG( msg, ... ) printf( msg, ##__VA_ARGS__ )
#define SYSLOG_MSG( msg, ... ) syslog( LOG_INFO, msg, ##__VA_ARGS__ )
#define LOG_MSG( msg, ... ) do { if( get_use_syslog() ) SYSLOG_MSG( msg, ##__VA_ARGS__ ); else PLOG_MSG( msg, ##__VA_ARGS__ ); } while(0)
#define PLOG_MSG(msg, ...) printf(msg, ##__VA_ARGS__)
#define SYSLOG_MSG(msg, ...) syslog(LOG_INFO, msg, ##__VA_ARGS__)
#define LOG_MSG(msg, ...) \
do { \
if (get_use_syslog()) { \
SYSLOG_MSG(msg, ##__VA_ARGS__); \
} else { \
PLOG_MSG(msg, ##__VA_ARGS__); \
} \
} while (0)
#define PLOG_ERROR( msg, ... ) fprintf( stderr, msg, ##__VA_ARGS__ )
#define SYSLOG_ERROR( msg, ... ) syslog( LOG_ERR, msg, ##__VA_ARGS__ )
#define LOG_ERROR( msg, ... ) do { if( get_use_syslog() ) SYSLOG_MSG( msg, ##__VA_ARGS__ ); else PLOG_MSG( msg, ##__VA_ARGS__ ); } while(0)
#define PLOG_ERROR(msg, ...) fprintf(stderr, msg, ##__VA_ARGS__)
#define SYSLOG_ERROR(msg, ...) syslog(LOG_ERR, msg, ##__VA_ARGS__)
#define LOG_ERROR(msg, ...) \
do { \
if (get_use_syslog()) { \
SYSLOG_MSG(msg, ##__VA_ARGS__); \
} else { \
PLOG_MSG(msg, ##__VA_ARGS__); \
} \
} while (0)
// Fatal errors trigger an exit
#define FATAL_ERRORNO( msg, ... ) do { LOG_ERROR( msg " (%s)\n", ##__VA_ARGS__, strerror(errno) ); exit(EXIT_FAILURE); } while(0)
#define FATAL_ERROR( msg, ... ) do { LOG_ERROR( msg, ##__VA_ARGS__ ); exit(EXIT_FAILURE); } while(0)
#define FATAL_ERRORNO(msg, ...) \
do { \
LOG_ERROR(msg " (%s)\n", ##__VA_ARGS__, strerror(errno)); \
exit(EXIT_FAILURE); \
} while (0)
#define FATAL_ERROR(msg, ...) \
do { \
LOG_ERROR(msg, ##__VA_ARGS__); \
exit(EXIT_FAILURE); \
} while (0)
// Control if we want to use the system logger
void set_use_syslog( const char* name );
void set_use_syslog(const char *name);
bool get_use_syslog();
#endif //_LOGGING_GAMEMODE_H_