mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 13:33:13 -07:00
Add Verbose Log Level
This commit is contained in:
parent
5d1d45543a
commit
b6cfb98022
4 changed files with 10 additions and 8 deletions
|
@ -28,13 +28,14 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CHIAKI_LOG_DEBUG = (1 << 3),
|
CHIAKI_LOG_DEBUG = (1 << 4),
|
||||||
|
CHIAKI_LOG_VERBOSE = (1 << 3),
|
||||||
CHIAKI_LOG_INFO = (1 << 2),
|
CHIAKI_LOG_INFO = (1 << 2),
|
||||||
CHIAKI_LOG_WARNING = (1 << 1),
|
CHIAKI_LOG_WARNING = (1 << 1),
|
||||||
CHIAKI_LOG_ERROR = (1 << 0)
|
CHIAKI_LOG_ERROR = (1 << 0)
|
||||||
} ChiakiLogLevel;
|
} 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);
|
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);
|
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_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_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_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)
|
#define CHIAKI_LOGE(log, ...) do { chiaki_log((log), CHIAKI_LOG_ERROR, __VA_ARGS__); } while(0)
|
||||||
|
|
|
@ -49,7 +49,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_session_init(ChiakiSession *session, Chiaki
|
||||||
{
|
{
|
||||||
memset(session, 0, sizeof(ChiakiSession));
|
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;
|
session->quit_reason = CHIAKI_QUIT_REASON_NONE;
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_stream_connection_run(ChiakiStreamConnectio
|
||||||
if(err != CHIAKI_ERR_SUCCESS)
|
if(err != CHIAKI_ERR_SUCCESS)
|
||||||
CHIAKI_LOGE(stream_connection->log, "StreamConnection failed to send heartbeat");
|
CHIAKI_LOGE(stream_connection->log, "StreamConnection failed to send heartbeat");
|
||||||
else
|
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);
|
err = chiaki_mutex_lock(&stream_connection->feedback_sender_mutex);
|
||||||
|
@ -390,7 +390,7 @@ static void stream_connection_takion_data_expect_bang(ChiakiStreamConnection *st
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHIAKI_LOGD(stream_connection->log, "Got a bang");
|
CHIAKI_LOGI(stream_connection->log, "BANG received");
|
||||||
|
|
||||||
if(!msg.bang_payload.version_accepted)
|
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
|
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];
|
uint8_t launch_spec_json_enc[LAUNCH_SPEC_JSON_BUF_SIZE];
|
||||||
memset(launch_spec_json_enc, 0, (size_t)launch_spec_json_size);
|
memset(launch_spec_json_enc, 0, (size_t)launch_spec_json_size);
|
||||||
|
|
|
@ -127,7 +127,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_buffer_push(ChiakiTakionSendBuf
|
||||||
packet->buf = buf;
|
packet->buf = buf;
|
||||||
packet->buf_size = buf_size;
|
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)
|
if(send_buffer->packets_count == 1)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_send_buffer_ack(ChiakiTakionSendBuff
|
||||||
send_buffer->packets_count -= shift;
|
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);
|
chiaki_mutex_unlock(&send_buffer->mutex);
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue