From b6cfb9802258009b37dfdd695ed17f300caaff4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Wed, 31 Jul 2019 17:38:40 +0200 Subject: [PATCH] Add Verbose Log Level --- lib/include/chiaki/log.h | 6 ++++-- lib/src/session.c | 2 +- lib/src/streamconnection.c | 6 +++--- lib/src/takionsendbuffer.c | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/include/chiaki/log.h b/lib/include/chiaki/log.h index fc30948..f77e427 100644 --- a/lib/include/chiaki/log.h +++ b/lib/include/chiaki/log.h @@ -28,13 +28,14 @@ extern "C" { #endif typedef enum { - CHIAKI_LOG_DEBUG = (1 << 3), + CHIAKI_LOG_DEBUG = (1 << 4), + CHIAKI_LOG_VERBOSE = (1 << 3), CHIAKI_LOG_INFO = (1 << 2), CHIAKI_LOG_WARNING = (1 << 1), CHIAKI_LOG_ERROR = (1 << 0) } ChiakiLogLevel; -#define CHIAKI_LOG_ALL ((1 << 4) - 1) +#define CHIAKI_LOG_ALL ((1 << 5) - 1) typedef void (*ChiakiLogCb)(ChiakiLogLevel level, const char *msg, void *user); @@ -57,6 +58,7 @@ CHIAKI_EXPORT void chiaki_log_hexdump(ChiakiLog *log, ChiakiLogLevel level, cons CHIAKI_EXPORT void chiaki_log_hexdump_raw(ChiakiLog *log, ChiakiLogLevel level, const uint8_t *buf, size_t buf_size); #define CHIAKI_LOGD(log, ...) do { chiaki_log((log), CHIAKI_LOG_DEBUG, __VA_ARGS__); } while(0) +#define CHIAKI_LOGV(log, ...) do { chiaki_log((log), CHIAKI_LOG_VERBOSE, __VA_ARGS__); } while(0) #define CHIAKI_LOGI(log, ...) do { chiaki_log((log), CHIAKI_LOG_INFO, __VA_ARGS__); } while(0) #define CHIAKI_LOGW(log, ...) do { chiaki_log((log), CHIAKI_LOG_WARNING, __VA_ARGS__); } while(0) #define CHIAKI_LOGE(log, ...) do { chiaki_log((log), CHIAKI_LOG_ERROR, __VA_ARGS__); } while(0) diff --git a/lib/src/session.c b/lib/src/session.c index e037d53..996ab94 100644 --- a/lib/src/session.c +++ b/lib/src/session.c @@ -49,7 +49,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_session_init(ChiakiSession *session, Chiaki { memset(session, 0, sizeof(ChiakiSession)); - chiaki_log_init(&session->log, CHIAKI_LOG_ALL, NULL, NULL); + chiaki_log_init(&session->log, CHIAKI_LOG_ALL & ~CHIAKI_LOG_VERBOSE, NULL, NULL); session->quit_reason = CHIAKI_QUIT_REASON_NONE; diff --git a/lib/src/streamconnection.c b/lib/src/streamconnection.c index 91e0aa5..be6cb00 100644 --- a/lib/src/streamconnection.c +++ b/lib/src/streamconnection.c @@ -232,7 +232,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_stream_connection_run(ChiakiStreamConnectio if(err != CHIAKI_ERR_SUCCESS) CHIAKI_LOGE(stream_connection->log, "StreamConnection failed to send heartbeat"); else - CHIAKI_LOGI(stream_connection->log, "StreamConnection sent heartbeat"); + CHIAKI_LOGV(stream_connection->log, "StreamConnection sent heartbeat"); } err = chiaki_mutex_lock(&stream_connection->feedback_sender_mutex); @@ -390,7 +390,7 @@ static void stream_connection_takion_data_expect_bang(ChiakiStreamConnection *st return; } - CHIAKI_LOGD(stream_connection->log, "Got a bang"); + CHIAKI_LOGI(stream_connection->log, "BANG received"); if(!msg.bang_payload.version_accepted) { @@ -585,7 +585,7 @@ static ChiakiErrorCode stream_connection_send_big(ChiakiStreamConnection *stream } launch_spec_json_size += 1; // we also want the trailing 0 - CHIAKI_LOGD(stream_connection->log, "LaunchSpec: %s", launch_spec_buf.json); + CHIAKI_LOGV(stream_connection->log, "LaunchSpec: %s", launch_spec_buf.json); uint8_t launch_spec_json_enc[LAUNCH_SPEC_JSON_BUF_SIZE]; memset(launch_spec_json_enc, 0, (size_t)launch_spec_json_size); diff --git a/lib/src/takionsendbuffer.c b/lib/src/takionsendbuffer.c index 3175ad6..c54f8dc 100644 --- a/lib/src/takionsendbuffer.c +++ b/lib/src/takionsendbuffer.c @@ -127,7 +127,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_buffer_push(ChiakiTakionSendBuf packet->buf = buf; packet->buf_size = buf_size; - CHIAKI_LOGD(send_buffer->log, "Pushed seq num %#llx into Takion Send Buffer", (unsigned long long)seq_num); + CHIAKI_LOGV(send_buffer->log, "Pushed seq num %#llx into Takion Send Buffer", (unsigned long long)seq_num); if(send_buffer->packets_count == 1) { @@ -192,7 +192,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_buffer_ack(ChiakiTakionSendBuff send_buffer->packets_count -= shift; } - CHIAKI_LOGD(send_buffer->log, "Acked seq num %#llx from Takion Send Buffer", (unsigned long long)seq_num); + CHIAKI_LOGV(send_buffer->log, "Acked seq num %#llx from Takion Send Buffer", (unsigned long long)seq_num); chiaki_mutex_unlock(&send_buffer->mutex); return err;