Replace die method with appropriate critical log
This commit is contained in:
parent
2c503c2984
commit
020a90e521
@ -14,6 +14,8 @@
|
||||
#define LOG_I g_info
|
||||
#define LOG_D g_debug
|
||||
|
||||
#define DIE(...) do { LOG_C(__VA_ARGS__); exit(EXIT_FAILURE); } while (0)
|
||||
|
||||
void dunst_log_init(bool testing);
|
||||
|
||||
#endif
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "utils.h"
|
||||
|
||||
typedef struct _entry_t {
|
||||
@ -42,7 +43,7 @@ section_t *new_section(const char *name)
|
||||
{
|
||||
for (int i = 0; i < section_count; i++) {
|
||||
if (!strcmp(name, sections[i].name)) {
|
||||
die("Duplicated section in dunstrc detected.\n", -1);
|
||||
DIE("Duplicated section in dunstrc detected.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "rules.h" // put before config.h to fix missing include
|
||||
#include "config.h"
|
||||
#include "dunst.h"
|
||||
#include "log.h"
|
||||
#include "notification.h"
|
||||
#include "option_parser.h"
|
||||
#include "utils.h"
|
||||
@ -85,10 +86,7 @@ void load_settings(char *cmdline_config_path)
|
||||
}
|
||||
|
||||
if(!config_file) {
|
||||
char *msg = g_strdup_printf(
|
||||
"Cannot find config file: '%s'\n",
|
||||
cmdline_config_path);
|
||||
die(msg, 1);
|
||||
DIE("Cannot find config file: '%s'", cmdline_config_path);
|
||||
}
|
||||
}
|
||||
if (config_file == NULL) {
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "log.h"
|
||||
|
||||
char *string_replace_char(char needle, char replacement, char *haystack)
|
||||
{
|
||||
char *current = haystack;
|
||||
@ -164,10 +166,4 @@ gint64 string_to_time(const char *string)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void die(char *text, int exit_value)
|
||||
{
|
||||
fputs(text, stderr);
|
||||
exit(exit_value);
|
||||
}
|
||||
|
||||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
||||
|
@ -21,9 +21,6 @@ char *string_append(char *a, const char *b, const char *sep);
|
||||
/* strip content between two delimiter characters (inplace) */
|
||||
void string_strip_delimited(char *str, char a, char b);
|
||||
|
||||
/* exit with an error message */
|
||||
void die(char *msg, int exit_value);
|
||||
|
||||
/* replace tilde and path-specific values with its equivalents */
|
||||
char *string_to_path(char *string);
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include "src/dbus.h"
|
||||
#include "src/dunst.h"
|
||||
#include "src/log.h"
|
||||
#include "src/markup.h"
|
||||
#include "src/notification.h"
|
||||
#include "src/queues.h"
|
||||
@ -996,7 +997,7 @@ void x_setup(void)
|
||||
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||
fputs("no locale support\n", stderr);
|
||||
if (!(xctx.dpy = XOpenDisplay(NULL))) {
|
||||
die("cannot open display\n", EXIT_FAILURE);
|
||||
DIE("Cannot open X11 display.");
|
||||
}
|
||||
|
||||
x_shortcut_init(&settings.close_ks);
|
||||
|
Loading…
x
Reference in New Issue
Block a user