mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-23 00:38:10 +02:00
Use os_log to report get_argv failures on Apple
This commit is contained in:
@@ -8,6 +8,9 @@
|
|||||||
#include "shlex.h"
|
#include "shlex.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "launcher.h"
|
#include "launcher.h"
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <os/log.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void
|
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);
|
char* src = read_full_file(filename, &src_sz);
|
||||||
if (!src) {
|
if (!src) {
|
||||||
if (errno == ENOENT || errno == ENOTDIR) return true;
|
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");
|
fprintf(stderr, "Failed to read from %s ", filename); perror("with error");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,8 +55,10 @@ log_error(const char *fmt, ...) {
|
|||||||
if (!use_os_log) { // Apple's os_log already records timestamps
|
if (!use_os_log) { // Apple's os_log already records timestamps
|
||||||
fprintf(stderr, "[%.3f] ", monotonic_t_to_s_double(monotonic()));
|
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__
|
#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
|
#endif
|
||||||
if (!use_os_log) fprintf(stderr, "%s\n", sanbuf);
|
if (!use_os_log) fprintf(stderr, "%s\n", sanbuf);
|
||||||
#undef bufprint
|
#undef bufprint
|
||||||
|
|||||||
Reference in New Issue
Block a user