Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions libcontainer/nsenter/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ bool log_enabled_for(int level);
void write_log(int level, const char *format, ...) __attribute__((format(printf, 2, 3)));

extern int logfd;
#define bail(fmt, ...) \
do { \
if (logfd < 0) \
fprintf(stderr, "FATAL: " fmt ": %m\n", \
##__VA_ARGS__); \
else \
write_log(FATAL, fmt ": %m", ##__VA_ARGS__); \
exit(1); \

/* bailx logs a message to logfd (or stderr, if logfd is not available)
* and terminates the program.
*/
#define bailx(fmt, ...) \
do { \
if (logfd < 0) \
fprintf(stderr, "FATAL: " fmt "\n", ##__VA_ARGS__); \
else \
write_log(FATAL, fmt, ##__VA_ARGS__); \
exit(1); \
} while(0)

/* bail is the same as bailx, except it also adds ": %m" (errno). */
#define bail(fmt, ...) bailx(fmt ": %m", ##__VA_ARGS__)

#endif /* NSENTER_LOG_H */
Loading