Commit 23a9aaf8 authored by Scott Vokes's avatar Scott Vokes
Browse files

Add timestamp before logging, make logging format consistent.

Also, eliminate extra newlines trailing some logging messages.
parent b4029eaf
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -164,7 +164,7 @@ static ssize_t socket_read_ssl(struct bus *b, listener *l, int pfd_i, connection
            switch (reason) {
            case SSL_ERROR_WANT_READ:
                BUS_LOG_SNPRINTF(b, 3, LOG_LISTENER, b->udata, 64,
                    "SSL_read fd %d: WANT_READ\n", ci->fd);
                    "SSL_read fd %d: WANT_READ", ci->fd);
                return accum;
                
            case SSL_ERROR_WANT_WRITE:
@@ -180,7 +180,7 @@ static ssize_t socket_read_ssl(struct bus *b, listener *l, int pfd_i, connection
                    continue;
                } else {
                    BUS_LOG_SNPRINTF(b, 3, LOG_LISTENER, b->udata, 64,
                        "SSL_read fd %d: errno %d\n", ci->fd, errno);
                        "SSL_read fd %d: errno %d", ci->fd, errno);
                    print_SSL_error(b, ci, 1, "SSL_ERROR_SYSCALL");
                    set_error_for_socket(l, pfd_i, ci->fd, RX_ERROR_READ_FAILURE);
                    return -1;
@@ -190,7 +190,7 @@ static ssize_t socket_read_ssl(struct bus *b, listener *l, int pfd_i, connection
            case SSL_ERROR_ZERO_RETURN:
            {
                BUS_LOG_SNPRINTF(b, 3, LOG_LISTENER, b->udata, 64,
                    "SSL_read fd %d: ZERO_RETURN (HUP)\n", ci->fd);
                    "SSL_read fd %d: ZERO_RETURN (HUP)", ci->fd);
                set_error_for_socket(l, pfd_i, ci->fd, RX_ERROR_POLLHUP);
                return -1;
            }
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ static ssize_t write_plain(struct bus *b, boxed_msg *box) {
            }
        } else if (wrsz > 0) {
            BUS_LOG_SNPRINTF(b, 5, LOG_SENDER, b->udata, 64,
                "sent: %zd\n", wrsz);
                "sent: %zd", wrsz);
            return wrsz;
        } else {
            return 0;
+5 −5
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ KineticACL_LoadFromFile(const char *path, struct ACL **instance) {
    }

#ifndef TEST
    LOGF2(" -- read %zd bytes, parsing...\n", buf_used);
    LOGF2(" -- read %zd bytes, parsing...", buf_used);
#endif
    res = acl_of_string(buf, buf_used, instance);
cleanup:
@@ -147,13 +147,13 @@ acl_of_string(const char *buf, size_t buf_size, struct ACL **instance) {
        size_t offset_out = 0;
        KineticProto_Command_Security_ACL *new_acl = NULL;
#ifndef TEST
        LOGF2(" -- reading next ACL at offset %zd, rem %zd\n", offset, buf_size - offset);
        LOGF2(" -- reading next ACL at offset %zd, rem %zd", offset, buf_size - offset);
#endif
        res = read_next_ACL(buf, buf_size, offset,
            &offset_out, tokener, &new_acl);
        offset += offset_out;
#ifndef TEST
        LOGF2(" -- result %d, offset_out %zd\n", res, offset);
        LOGF2(" -- result %d, offset_out %zd", res, offset);
#endif
        if (res == ACL_OK) {
            if (acl_group->ACL_count == acl_group->ACL_ceil) {  /* grow */
@@ -178,7 +178,7 @@ cleanup:
    
    if (res == ACL_END_OF_STREAM || res == ACL_OK) {
        if (acl_group && acl_group->ACL_count == 0) {
            LOG2("Failed to read any JSON objects\n");
            LOG2("Failed to read any JSON objects");
            return ACL_ERROR_BAD_JSON;
        } else {            /* read at least one ACL */
            *instance = acl_group;
@@ -200,7 +200,7 @@ static KineticACLLoadResult read_next_ACL(const char *buf, size_t buf_size,
        if (json_tokener_get_error(tokener) == json_tokener_error_parse_eof) {
            return ACL_END_OF_STREAM;
        } else {
            LOGF2("JSON error %d\n", json_tokener_get_error(tokener));
            LOGF2("JSON error %d", json_tokener_get_error(tokener));
            return ACL_ERROR_BAD_JSON;
        }
    }
+2 −10
Original line number Diff line number Diff line
@@ -36,15 +36,7 @@
STATIC void log_cb(log_event_t event, int log_level, const char *msg, void *udata) {
    (void)udata;
    const char *event_str = Bus_LogEventStr(event);
    struct timeval tv;
    gettimeofday(&tv, NULL);
#if 0
    KineticLogger_Log(log_level, msg);
#else
    LOGF0("%ld.%06ld: %s[%d] -- %s\n",
        (long)tv.tv_sec, (long)tv.tv_usec,
        event_str, log_level, msg);
#endif
    KineticLogger_LogPrintf(log_level, "%s[%d] %s", event_str, log_level, msg);
}

static bus_sink_cb_res_t reset_transfer(socket_info *si) {
@@ -266,7 +258,7 @@ bool KineticBus_Init(KineticClient * client, KineticClientConfig * config)
    bus_result res;
    memset(&res, 0, sizeof(res));
    if (!Bus_Init(&cfg, &res)) {
        LOGF0("failed to init bus: %d\n", res.status);
        LOGF0("failed to init bus: %d", res.status);
        return false;
    }
    client->bus = res.bus;
+4 −4
Original line number Diff line number Diff line
@@ -141,13 +141,13 @@ KineticStatus bus_to_kinetic_status(bus_send_status_t const status)
        case BUS_SEND_UNDEFINED:
        default:
        {
            LOGF0("bus_to_kinetic_status: UNMATCHED %d\n", status);
            LOGF0("bus_to_kinetic_status: UNMATCHED %d", status);
            KINETIC_ASSERT(false);
            return KINETIC_STATUS_INVALID;
        }
    }
    
    LOGF3("bus_to_kinetic_status: mapping status %d => %d\n",
    LOGF3("bus_to_kinetic_status: mapping status %d => %d",
        status, res);
    return res;
}
@@ -214,7 +214,7 @@ void KineticController_HandleUnexpectedResponse(void *msg,
        }
    }
    else {
        KineticLogger_LogTimestamp(0, "WARNING: Received unexpected response!");
        LOG0("WARNING: Received unexpected response!");
        logTag = unexpectedTag;
        logAtLevel = 0;
        protoLogAtLevel = 0;
@@ -268,7 +268,7 @@ void KineticController_HandleResult(bus_msg_result_t *res, void *udata)
    } else {
        LOGF0("Error receiving response, got message bus error: %s", bus_error_string(res->status));
        if (res->status == BUS_SEND_RX_TIMEOUT) {
            KineticLogger_LogTimestamp(0, "RX_TIMEOUT");
            LOG0("RX_TIMEOUT");
        }
    }

Loading