diff --git a/kitty/launcher/cmdline.c b/kitty/launcher/cmdline.c index 6fc8c42bf..7348d3c12 100644 --- a/kitty/launcher/cmdline.c +++ b/kitty/launcher/cmdline.c @@ -8,6 +8,9 @@ #include "shlex.h" #include "utils.h" #include "launcher.h" +#ifdef __APPLE__ +#include +#endif void @@ -46,6 +49,11 @@ get_argv_from(const char *filename, const char *argv0, argv_array *final_ans) { char* src = read_full_file(filename, &src_sz); if (!src) { if (errno == ENOENT || errno == ENOTDIR) return true; +#ifdef __APPLE__ + int saved = errno; + os_log_error(OS_LOG_DEFAULT, "Failed to read from %s with error: %{darwin.errno}d", filename, errno); + errno = saved; +#endif fprintf(stderr, "Failed to read from %s ", filename); perror("with error"); return true; } diff --git a/kitty/logging.c b/kitty/logging.c index e874143f2..3630ed482 100644 --- a/kitty/logging.c +++ b/kitty/logging.c @@ -55,8 +55,10 @@ log_error(const char *fmt, ...) { if (!use_os_log) { // Apple's os_log already records timestamps fprintf(stderr, "[%.3f] ", monotonic_t_to_s_double(monotonic())); } + // To see os_log messages from kitty, use: + // log show --predicate 'processImagePath contains "kitty"' #ifdef __APPLE__ - if (use_os_log) os_log(OS_LOG_DEFAULT, "%{public}s", sanbuf); + if (use_os_log) os_log_error(OS_LOG_DEFAULT, "%{public}s", sanbuf); #endif if (!use_os_log) fprintf(stderr, "%s\n", sanbuf); #undef bufprint