mirror of
https://github.com/swaywm/sway.git
synced 2025-11-07 13:29:56 -05:00
properly handle IPC clients
This commit is contained in:
parent
5d99215469
commit
773e85c681
3 changed files with 163 additions and 61 deletions
30
sway/log.c
30
sway/log.c
|
|
@ -5,6 +5,8 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
int colored = 1;
|
||||
int v = 0;
|
||||
|
|
@ -66,6 +68,34 @@ void sway_log(int verbosity, const char* format, ...) {
|
|||
}
|
||||
}
|
||||
|
||||
void sway_log_errno(int verbosity, char* format, ...) {
|
||||
if (verbosity <= v) {
|
||||
int c = verbosity;
|
||||
if (c > sizeof(verbosity_colors) / sizeof(char *)) {
|
||||
c = sizeof(verbosity_colors) / sizeof(char *) - 1;
|
||||
}
|
||||
|
||||
if (colored) {
|
||||
fprintf(stderr, verbosity_colors[c]);
|
||||
}
|
||||
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
|
||||
fprintf(stderr, ": ");
|
||||
char error[256];
|
||||
strerror_r(errno, error, sizeof(error));
|
||||
fprintf(stderr, error);
|
||||
|
||||
if (colored) {
|
||||
fprintf(stderr, "\x1B[0m");
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
bool sway_assert(bool condition, const char* format, ...) {
|
||||
if (condition) {
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue