Commit 99f2d808 authored by Scott Vokes's avatar Scott Vokes
Browse files

Add KineticLogger_LogTimestamp and log time on unexpected messages.

parent 5debeae6
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -226,7 +226,7 @@ void KineticController_HandleUnexpectedResponse(void *msg,
    }
    else
    {
        LOG0("WARNING: Received unexpected response!");
        KineticLogger_LogTimestamp(0, "WARNING: Received unexpected response!");
        logTag = unexpectedTag;
        logAtLevel = 0;
        protoLogAtLevel = 0;
@@ -288,6 +288,9 @@ void KineticController_HandleResult(bus_msg_result_t *res, void *udata)
    {
        // pull out bus error?
        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");
        }
    }

    // Call operation-specific callback, if configured
+12 −0
Original line number Diff line number Diff line
@@ -518,6 +518,18 @@ void KineticLogger_LogByteBuffer(int log_level, const char* title, ByteBuffer bu
    KineticLogger_LogByteArray(log_level, title, array);
}

void KineticLogger_LogTimestamp(int log_level, const char* title) {
    struct timeval tv;
    if (title == NULL) {
        title = "";
    }
    if (0 == gettimeofday(&tv, NULL)) {
        KineticLogger_LogPrintf(log_level, "%s: %lld.%lld\n",
            title, (long long)tv.tv_sec, (long long)tv.tv_usec);
    } else {
        KineticLogger_LogPrintf(0, "%s: (gettimeofday failure)", title);
    }
}

//------------------------------------------------------------------------------
// Private Method Definitions
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ void KineticLogger_LogProtobuf(int log_level, const KineticProto_Message* msg);
void KineticLogger_LogStatus(int log_level, KineticProto_Command_Status* status);
void KineticLogger_LogByteArray(int log_level, const char* title, ByteArray bytes);
void KineticLogger_LogByteBuffer(int log_level, const char* title, ByteBuffer buffer);
void KineticLogger_LogTimestamp(int log_level, const char* title);

int KineticLogger_ByteArraySliceToCString(char* p_buf, const ByteArray bytes, const int start, const int count);
#define BYTES_TO_CSTRING(_buf_start, _array, _array_start, _count) { \