Skip to content

Commit c86e5d2

Browse files
committed
CDRIVER-900: Print debug error messaging to stderr
1 parent 904869e commit c86e5d2

File tree

10 files changed

+22
-22
lines changed

10 files changed

+22
-22
lines changed

tests/ha-test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ ha_replica_set_wait_for_healthy (ha_replica_set_t *replica_set)
789789
char *str;
790790

791791
str = bson_as_json(&status, NULL);
792-
printf("%s\n", str);
792+
fprintf(stderr, "%s\n", str);
793793
bson_free(str);
794794
}
795795
#endif
@@ -952,7 +952,7 @@ ha_config_add_shard (ha_node_t *node,
952952
char *str;
953953

954954
str = bson_as_json (&reply, NULL);
955-
printf ("%s\n", str);
955+
fprintf (stderr, "%s\n", str);
956956
bson_free (str);
957957
}
958958
#endif

tests/json-test.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ topology_type_from_test(const char *type)
3737
} else if (strcmp(type, "Sharded") == 0) {
3838
return MONGOC_TOPOLOGY_SHARDED;
3939
} else {
40-
printf("can't parse this: %s", type);
40+
fprintf(stderr, "can't parse this: %s", type);
4141
assert(0);
4242
}
4343
}
@@ -64,7 +64,7 @@ server_type_from_test(const char *type)
6464
} else if (strcmp(type, "Unknown") == 0) {
6565
return MONGOC_SERVER_UNKNOWN;
6666
} else {
67-
printf("ERROR: Unknown server type %s\n", type);
67+
fprintf(stderr, "ERROR: Unknown server type %s\n", type);
6868
assert(0);
6969
}
7070
}
@@ -85,7 +85,7 @@ topology_type_to_string(mongoc_topology_description_type_t type)
8585
return "Single";
8686
case MONGOC_TOPOLOGY_DESCRIPTION_TYPES:
8787
default:
88-
printf("ERROR: Unknown topology state\n");
88+
fprintf(stderr, "ERROR: Unknown topology state\n");
8989
assert(0);
9090
}
9191
}
@@ -296,7 +296,7 @@ install_json_test_suite(TestSuite *suite, const char *dir_path, test_hook callba
296296

297297
TestSuite_AddWC(suite, skip_json, (void (*)(void *))callback, (void (*)(void*))bson_destroy, test);
298298
} else {
299-
printf("NO DATA\n");
299+
fprintf(stderr, "NO DATA\n");
300300
}
301301
}
302302
}

tests/mock_server/mock-server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ mock_server_run (mock_server_t *server)
311311
mongoc_mutex_unlock (&server->mutex);
312312

313313
if (mock_server_get_verbose (server)) {
314-
printf ("listening on port %hu\n", bound_port);
314+
fprintf (stderr, "listening on port %hu\n", bound_port);
315315
fflush (stdout);
316316
}
317317

tests/test-bulk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ test_bulk_write_concern_over_1000(void)
24762476
success = mongoc_cursor_next (cursor, &result);
24772477
if (!success) {
24782478
mongoc_cursor_error(cursor, &error);
2479-
printf("%s", error.message);
2479+
fprintf(stderr, "%s", error.message);
24802480
}
24812481
assert(success);
24822482

tests/test-libmongoc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -514,8 +514,8 @@ call_ismaster (bson_t *reply)
514514
tmp_bson ("{'isMaster': 1}"),
515515
NULL, reply, &error)) {
516516

517-
printf ("error calling ismaster: '%s'\n", error.message);
518-
printf ("URI = %s\n", uri_str);
517+
fprintf (stderr, "error calling ismaster: '%s'\n", error.message);
518+
fprintf (stderr, "URI = %s\n", uri_str);
519519
abort ();
520520
}
521521

tests/test-mongoc-client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ test_mongoc_client_authenticate (void *context)
103103
if (!r) {
104104
r = mongoc_cursor_error(cursor, &error);
105105
if (r) {
106-
printf("Authentication failure: \"%s\"", error.message);
106+
fprintf (stderr, "Authentication failure: \"%s\"", error.message);
107107
}
108108
assert(!r);
109109
}

tests/test-mongoc-exhaust.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ test_exhaust_cursor (bool pooled)
136136
r = mongoc_cursor_next (cursor, &doc);
137137
if (!r) {
138138
mongoc_cursor_error (cursor, &error);
139-
printf ("cursor error: %s\n", error.message);
139+
fprintf (stderr, "cursor error: %s\n", error.message);
140140
}
141141
assert (r);
142142
assert (doc);
@@ -159,7 +159,7 @@ test_exhaust_cursor (bool pooled)
159159
r = mongoc_cursor_next (cursor2, &doc);
160160
if (!r) {
161161
mongoc_cursor_error (cursor2, &error);
162-
printf ("cursor error: %s\n", error.message);
162+
fprintf (stderr, "cursor error: %s\n", error.message);
163163
}
164164
assert (r);
165165
assert (doc);
@@ -169,7 +169,7 @@ test_exhaust_cursor (bool pooled)
169169
r = mongoc_cursor_next (cursor2, &doc);
170170
if (!r) {
171171
mongoc_cursor_error (cursor2, &error);
172-
printf ("cursor error: %s\n", error.message);
172+
fprintf (stderr, "cursor error: %s\n", error.message);
173173
}
174174
assert (r);
175175
assert (doc);

tests/test-mongoc-matcher.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test_mongoc_matcher_basic (void)
4040
#if 0
4141
{
4242
char *out = bson_as_json(&matcher_query, NULL);
43-
printf("bson: %s\n", out);
43+
fprintf(stderr, "bson: %s\n", out);
4444
free(out);
4545
}
4646
#endif

tests/test-mongoc-rpc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ assert_rpc_equal (const char *filename,
7171
_mongoc_rpc_gather(rpc, &ar);
7272

7373
#if 0
74-
printf("Before swabbing\n");
75-
printf("=========================\n");
74+
fprintf(stderr, "Before swabbing\n");
75+
fprintf(stderr, "=========================\n");
7676
mongoc_rpc_printf(rpc);
7777
#endif
7878

7979
_mongoc_rpc_swab_to_le(rpc);
8080

8181
#if 0
82-
printf("After swabbing\n");
83-
printf("=========================\n");
82+
fprintf(stderr, "After swabbing\n");
83+
fprintf(stderr, "=========================\n");
8484
mongoc_rpc_printf(rpc);
8585
#endif
8686

@@ -89,7 +89,7 @@ assert_rpc_equal (const char *filename,
8989
ASSERT(iov->iov_len <= (length - off));
9090
r = memcmp(&data[off], iov->iov_base, iov->iov_len);
9191
if (r) {
92-
printf("\nError iovec: %u\n", i);
92+
fprintf(stderr, "\nError iovec: %u\n", i);
9393
}
9494
ASSERT(r == 0);
9595
off += iov->iov_len;

tests/test-mongoc-sdam.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ _topology_has_description(mongoc_topology_description_t *topology,
6060
} else if (strcmp("type", bson_iter_key (&server_iter)) == 0) {
6161
assert (sd->type == server_type_from_test(bson_iter_utf8(&server_iter, NULL)));
6262
} else {
63-
printf ("ERROR: unparsed field %s\n", bson_iter_key(&server_iter));
63+
fprintf (stderr, "ERROR: unparsed field %s\n", bson_iter_key(&server_iter));
6464
assert (0);
6565
}
6666
}
@@ -172,7 +172,7 @@ test_sdam_cb (bson_t *test)
172172
topology_type_to_string(client->topology->description.type),
173173
bson_iter_utf8(&outcome_iter, NULL));
174174
} else {
175-
printf ("ERROR: unparsed test field %s\n", bson_iter_key (&outcome_iter));
175+
fprintf (stderr, "ERROR: unparsed test field %s\n", bson_iter_key (&outcome_iter));
176176
assert (false);
177177
}
178178
}

0 commit comments

Comments
 (0)