feat(src/common): replace errorf with LOG_ERROR and add verbose flag

New Features
- None

Enhancements
- Use LOG_ERROR for consistent error logging; add g_verbose flag.

Bug Fixes
- Remove deprecated errorf function.
This commit is contained in:
sankalp committed 2026-02-22 02:35:22 +05:45
1 parent 563ebdbbab
commit 21cada4969
1 file changed
+4 -9
+4 -9
View File
@@ -1,5 +1,6 @@
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include "common/utils.h" #include "common/utils.h"
#include "common/log.h"
#include <pwd.h> #include <pwd.h>
#include <signal.h> #include <signal.h>
#include <stdarg.h> #include <stdarg.h>
@@ -8,6 +9,8 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
int g_verbose = 0;
int read_runtime_mute_file() { int read_runtime_mute_file() {
char mute_file[1024]; char mute_file[1024];
const char *rd = getenv("XDG_RUNTIME_DIR"); const char *rd = getenv("XDG_RUNTIME_DIR");
@@ -66,14 +69,6 @@ int safe_snprintf(char *dst, size_t dst_sz, const char *fmt, ...) {
return (n >= 0 && (size_t)n < dst_sz); return (n >= 0 && (size_t)n < dst_sz);
} }
int errorf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
return 1;
}
const char *get_runtime_dir(void) { const char *get_runtime_dir(void) {
const char *rd = getenv("XDG_RUNTIME_DIR"); const char *rd = getenv("XDG_RUNTIME_DIR");
if (rd && strlen(rd) > 0) if (rd && strlen(rd) > 0)
@@ -176,7 +171,7 @@ void safe_strncpy(char *dest, const char *src, size_t dest_size) {
// Helper to print error and close file // Helper to print error and close file
void print_error_and_close_file(FILE *file, const char *error_msg, const char *filename) { void print_error_and_close_file(FILE *file, const char *error_msg, const char *filename) {
if (file) fclose(file); if (file) fclose(file);
safe_fprintf(stderr, "Error: %s %s\n", error_msg, filename ? filename : ""); LOG_ERROR("Error: %s %s", error_msg, filename ? filename : "");
} }
// Safe wrapper for fscanf with bounds checking // Safe wrapper for fscanf with bounds checking