summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3724686)
raw | patch | inline | side by side (parent: 3724686)
author | Sebastian Harl <sh@tokkee.org> | |
Thu, 11 Dec 2014 23:24:20 +0000 (00:24 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Thu, 11 Dec 2014 23:30:43 +0000 (00:30 +0100) |
src/tools/sysdb/command.c | patch | blob | history | |
src/tools/sysdb/input.c | patch | blob | history | |
t/integration/query.sh | patch | blob | history |
index 6ae4c89a981eff70cdf9fb8413f8211f6e90e9dc..9589875300d468c7b9e6b7268fef5705a9580773 100644 (file)
uint32_t prio = sdb_proto_get_int(buf, 0);
if (prio == UINT32_MAX) {
- printf("ERROR: Received a LOG message with invalid "
- "or missing priority\n");
- return;
+ sdb_log(SDB_LOG_WARNING, "Received a LOG message with invalid "
+ "or missing priority");
+ prio = (uint32_t)SDB_LOG_ERR;
}
sdb_strbuf_skip(buf, 0, sizeof(prio));
- printf("%s: %s\n", SDB_LOG_PRIO_TO_STRING((int)prio),
- sdb_strbuf_string(buf));
+ sdb_log((int)prio, "%s", sdb_strbuf_string(buf));
} /* log_printer */
static void
return;
}
else if (len < sizeof(uint32_t)) {
- printf("ERROR: Received a DATA message with invalid "
- "or missing data-type\n");
+ sdb_log(SDB_LOG_ERR, "Received a DATA message with invalid "
+ "or missing data-type");
return;
}
const char *result;
uint32_t rcode = 0;
- int status = 0;
+ int status = -1;
size_t i;
recv_buf = sdb_strbuf_create(1024);
return -1;
}
- if (rcode == UINT32_MAX) {
- printf("ERROR: ");
- status = -1;
- }
- else
+ if (rcode != UINT32_MAX)
status = (int)rcode;
for (i = 0; i < SDB_STATIC_ARRAY_LEN(response_printers); ++i) {
result = sdb_strbuf_string(recv_buf);
if (result && *result)
- printf("%s\n", result);
+ sdb_log(SDB_LOG_ERR, "%s", result);
else if (rcode == UINT32_MAX) {
char errbuf[1024];
- printf("%s\n", sdb_strerror(errno, errbuf, sizeof(errbuf)));
+ sdb_log(SDB_LOG_ERR, "%s",
+ sdb_strerror(errno, errbuf, sizeof(errbuf)));
}
sdb_strbuf_destroy(recv_buf);
index 898464af0b550118aa0367337a4e4b85460930c6..b6603c08ed86aef9aa7aa5ac956634f4aafd888f 100644 (file)
--- a/src/tools/sysdb/input.c
+++ b/src/tools/sysdb/input.c
if (sdb_client_eof(sysdb_input->client)) {
rl_callback_handler_remove();
/* XXX */
- printf("Remote side closed the connection.\n");
+ sdb_log(SDB_LOG_ERR, "Remote side closed the connection.");
/* return EOF -> restart scanner */
return 0;
}
{
sdb_client_close(sysdb_input->client);
if (sdb_client_connect(sysdb_input->client, sysdb_input->user)) {
- printf("Failed to reconnect to SysDBd.\n");
+ sdb_log(SDB_LOG_ERR, "Failed to reconnect to SysDBd");
return -1;
}
- printf("Successfully reconnected to SysDBd.\n");
+ sdb_log(SDB_LOG_INFO, "Successfully reconnected to SysDBd");
return 0;
} /* sdb_input_reconnect */
diff --git a/t/integration/query.sh b/t/integration/query.sh
index 39522cf9be6c09928952f121b621b6121286e54a..f8287b45a645adac6798dbb611b092279e070d4f 100755 (executable)
--- a/t/integration/query.sh
+++ b/t/integration/query.sh
sleep 3
# On parse errors, expect a non-zero exit code.
-output="$( run_sysdb -H "$SOCKET_FILE" -c INVALID )" && exit 1
+output="$( run_sysdb -H "$SOCKET_FILE" -c INVALID 2>&1 )" && exit 1
echo "$output" | grep "Failed to parse query 'INVALID'"
echo "$output" | grep "parse error: syntax error"
echo "$output" | grep -F 'some.host.name' && exit 1
output="$( run_sysdb -H "$SOCKET_FILE" \
- -c "FETCH host 'host1.example.com' FILTER last_update < 0" )" \
+ -c "FETCH host 'host1.example.com' FILTER last_update < 0" 2>&1 )" \
&& exit 1
echo "$output" | grep -F 'not found'
| run_sysdb -H "$SOCKET_FILE"
# When requesting information for unknown hosts, expect a non-zero exit code.
-output="$( run_sysdb -H "$SOCKET_FILE" -c "FETCH host 'does.not.exist'" )" \
- && exit 1
+output="$( run_sysdb -H "$SOCKET_FILE" \
+ -c "FETCH host 'does.not.exist'" 2>&1 )" && exit 1
echo "$output" | grep -F 'not found'
run_sysdb -H "$SOCKET_FILE" \