Skip to content

Commit

Permalink
Merge pull request #1184 from JerziKaminsky/logging2
Browse files Browse the repository at this point in the history
More Logging Fixes
  • Loading branch information
ddevault authored Apr 20, 2017
2 parents 382b678 + 39a65a6 commit d2de522
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
19 changes: 9 additions & 10 deletions common/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ void sway_log_colors(int mode) {
colored = (mode == 1) ? 1 : 0;
}

void sway_abort(const char *format, ...) {
fprintf(stderr, "ERROR: ");
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
fprintf(stderr, "\n");
sway_terminate(EXIT_FAILURE);
}

void _sway_vlog(const char *filename, int line, log_importance_t verbosity,
const char *format, va_list args) {
if (verbosity <= v) {
Expand Down Expand Up @@ -116,6 +106,15 @@ void _sway_log(const char *filename, int line, log_importance_t verbosity, const
va_end(args);
}


void _sway_abort(const char *filename, int line, const char* format, ...) {
va_list args;
va_start(args, format);
_sway_vlog(filename, line, L_ERROR, format, args);
va_end(args);
sway_terminate(EXIT_FAILURE);
}

void sway_log_errno(log_importance_t verbosity, char* format, ...) {
if (verbosity <= v) {
unsigned int c = verbosity;
Expand Down
5 changes: 4 additions & 1 deletion include/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ void reset_log_level(void);
bool toggle_debug_logging(void);
void sway_log_colors(int mode);
void sway_log_errno(log_importance_t verbosity, char* format, ...) __attribute__((format(printf,2,3)));
void sway_abort(const char* format, ...) __attribute__((format(printf,1,2)));

void _sway_abort(const char *filename, int line, const char* format, ...) __attribute__((format(printf,3,4)));
#define sway_abort(FMT, ...) \
_sway_abort(__FILE__, __LINE__, FMT, ##__VA_ARGS__)

bool _sway_assert(bool condition, const char *filename, int line, const char* format, ...) __attribute__((format(printf,4,5)));
#define sway_assert(COND, FMT, ...) \
Expand Down

0 comments on commit d2de522

Please sign in to comment.