Skip to content

Commit a93c3fe

Browse files
authored
Only output on nix verbose builds and only output to stderr (#87)
Prevent any output on non verbose nix builds and only output to stderr on verbose builds to avoid introducing unexpected output from non unity processes that UnityDoorstop gets injected into.
1 parent 5c52b96 commit a93c3fe

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/nix/entrypoint.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ __attribute__((constructor)) void doorstop_ctor() {
117117
}
118118

119119
if (plthook_replace(hook, "dlsym", &dlsym_hook, NULL) != 0)
120-
printf("Failed to hook dlsym, ignoring it. Error: %s\n",
120+
LOG("Failed to hook dlsym, ignoring it. Error: %s",
121121
plthook_error());
122122

123123
if (config.boot_config_override) {
@@ -132,11 +132,11 @@ __attribute__((constructor)) void doorstop_ctor() {
132132

133133
#if !defined(__APPLE__)
134134
if (plthook_replace(hook, "fopen64", &fopen64_hook, NULL) != 0)
135-
printf("Failed to hook fopen64, ignoring it. Error: %s\n",
135+
LOG("Failed to hook fopen64, ignoring it. Error: %s",
136136
plthook_error());
137137
#endif
138138
if (plthook_replace(hook, "fopen", &fopen_hook, NULL) != 0)
139-
printf("Failed to hook fopen, ignoring it. Error: %s\n",
139+
LOG("Failed to hook fopen, ignoring it. Error: %s",
140140
plthook_error());
141141
} else {
142142
LOG("The boot.config file won't be overriden because the provided "
@@ -146,11 +146,11 @@ __attribute__((constructor)) void doorstop_ctor() {
146146
}
147147

148148
if (plthook_replace(hook, "fclose", &fclose_hook, NULL) != 0)
149-
printf("Failed to hook fclose, ignoring it. Error: %s\n",
149+
LOG("Failed to hook fclose, ignoring it. Error: %s",
150150
plthook_error());
151151

152152
if (plthook_replace(hook, "dup2", &dup2_hook, NULL) != 0)
153-
printf("Failed to hook dup2, ignoring it. Error: %s\n",
153+
LOG("Failed to hook dup2, ignoring it. Error: %s",
154154
plthook_error());
155155

156156
#if defined(__APPLE__)
@@ -162,7 +162,7 @@ __attribute__((constructor)) void doorstop_ctor() {
162162
void *mono_handle = plthook_handle_by_name("libmono");
163163

164164
if (plthook_replace(hook, "mono_jit_init_version", &init_mono, NULL) != 0)
165-
printf("Failed to hook jit_init_version, ignoring it. This is probably fine unless you see other errors. Error: %s\n",
165+
LOG("Failed to hook jit_init_version, ignoring it. This is probably fine unless you see other errors. Error: %s",
166166
plthook_error());
167167
else if (mono_handle)
168168
load_mono_funcs(mono_handle);

src/nix/logger.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
#define LOGGER_NIX_H
33
#if VERBOSE
44

5-
#define LOG(message, ...) printf("[Doorstop] " message "\n", ##__VA_ARGS__)
5+
#define LOG(message, ...) fprintf(stderr, "[Doorstop] " message "\n", ##__VA_ARGS__)
66

77
#define ASSERT_F(test, message, ...) \
88
if (!(test)) { \
9-
printf("[Doorstop][Fatal] " message "\n", ##__VA_ARGS__); \
9+
fprintf(stderr, "[Doorstop][Fatal] " message "\n", ##__VA_ARGS__); \
1010
exit(1); \
1111
}
1212

1313
#define ASSERT(test, message) \
1414
if (!(test)) { \
15-
printf("[Doorstop][Fatal] " message "\n"); \
15+
fprintf(stderr, "[Doorstop][Fatal] " message "\n"); \
1616
exit(1); \
1717
}
1818

0 commit comments

Comments
 (0)