Skip to content

Commit 7e9860b

Browse files
committed
log to stderr, not stdout
stdout is the wrong stream for this; human-readable logs should go to stderr.
1 parent 27b446d commit 7e9860b

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

GhostServer/main_cli.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ int main(int argc, char **argv) {
2222
});
2323

2424
if (argc > 3 || (argc == 2 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))) {
25-
printf("Usage: %s [port] [logfile]\n", argv[0]);
25+
fprintf(stderr, "Usage: %s [port] [logfile]\n", argv[0]);
2626
return 1;
2727
}
2828

2929
int port = 53000;
3030
if (argc >= 2) {
3131
port = atoi(argv[1]);
3232
if (port < 1 || port > 65535) {
33-
printf("Invalid port %d\n", port);
33+
fprintf(stderr, "Invalid port %d\n", port);
3434
return 1;
3535
}
3636
}
@@ -45,7 +45,7 @@ int main(int argc, char **argv) {
4545

4646
puts("Server starting up");
4747
if (!network.StartServer(port)) {
48-
printf("Failed to start server on port %d\n", port);
48+
fprintf(stderr, "Failed to start server on port %d\n", port);
4949
return 1;
5050
}
5151
while (!g_should_stop) {

GhostServer/networkmanager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static void file_log(std::string str) {
2525
# define GHOST_LOG(x) (file_log(x), emit this->OnNewEvent(QString::fromStdString(x)))
2626
#else
2727
# include <stdio.h>
28-
# define GHOST_LOG(x) (file_log(x), printf("[LOG] %s\n", std::string(x).c_str()))
28+
# define GHOST_LOG(x) (file_log(x), fprintf(stderr, "[LOG] %s\n", std::string(x).c_str()))
2929
#endif
3030

3131
#define HEARTBEAT_RATE 5000

0 commit comments

Comments
 (0)