More small changes

This commit is contained in:
XorTroll 2020-05-07 17:24:21 +02:00
parent 3de44a48f8
commit f1ad24b7cc
2 changed files with 29 additions and 29 deletions

View File

@ -11,10 +11,10 @@
/// DiagLogSeverity
typedef enum {
DiagLogSeverity_Trace = 0,
DiagLogSeverity_Info = 1,
DiagLogSeverity_Warn = 2,
DiagLogSeverity_Info = 1,
DiagLogSeverity_Warn = 2,
DiagLogSeverity_Error = 3,
DiagLogSeverity_Fatal = 4
DiagLogSeverity_Fatal = 4,
} DiagLogSeverity;
/// DiagSourceInfo
@ -57,13 +57,13 @@ void diagLogImpl(const DiagLogMetadata *metadata);
#define DIAG_DETAILED_LOGF(log_severity, log_verbosity, fmt, ...) ({ \
char msg[0x400] = {}; \
snprintf(msg, 0x400, fmt, ##__VA_ARGS__); \
snprintf(msg, sizeof(msg), fmt, ##__VA_ARGS__); \
DIAG_DETAILED_LOG(log_severity, log_verbosity, msg); \
})
#define DIAG_DETAILED_VLOG(log_severity, log_verbosity, fmt, args) ({ \
char msg[0x400] = {}; \
vsnprintf(msg, 0x400, fmt, args); \
vsnprintf(msg, sizeof(msg), fmt, args); \
DIAG_DETAILED_LOG(log_severity, log_verbosity, msg); \
})

View File

@ -8,40 +8,40 @@ static Mutex g_logMutex;
/// DiagLogPacketFlags
typedef enum {
DiagLogPacketFlags_Head = BIT(0), ///< First packet.
DiagLogPacketFlags_Tail = BIT(1) ///< Last packet.
DiagLogPacketFlags_Head = BIT(0), ///< First packet.
DiagLogPacketFlags_Tail = BIT(1), ///< Last packet.
} DiagLogPacketFlags;
/// DiagLogPacketHeader
typedef struct {
u64 process_id; ///< Process ID.
u64 thread_id; ///< Thread ID.
u8 flags; ///< \ref DiagLogPacketFlags
u8 pad; ///< Padding
u8 severity; ///< \ref DiagLogSeverity
u8 verbosity; ///< Verbosity.
u32 payload_size; ///< Total packet size after this header.
u64 process_id; ///< Process ID.
u64 thread_id; ///< Thread ID.
u8 flags; ///< \ref DiagLogPacketFlags
u8 pad; ///< Padding
u8 severity; ///< \ref DiagLogSeverity
u8 verbosity; ///< Verbosity.
u32 payload_size; ///< Total packet size after this header.
} DiagLogPacketHeader;
/// DiagLogDataChunkKey
typedef enum {
DiagLogDataChunkKey_LogSessionBegin = 0, ///< Log session begin (unknown)
DiagLogDataChunkKey_LogSessionEnd = 1, ///< Log session end (unknown)
DiagLogDataChunkKey_TextLog = 2, ///< Text to be logged.
DiagLogDataChunkKey_LineNumber = 3, ///< Source line number.
DiagLogDataChunkKey_FileName = 4, ///< Source file name.
DiagLogDataChunkKey_FunctionName = 5, ///< Source function name.
DiagLogDataChunkKey_ModuleName = 6, ///< Process module name.
DiagLogDataChunkKey_ThreadName = 7, ///< Process thread name.
DiagLogDataChunkKey_LogPacketDropCount = 8, ///< Log packet drop count (unknown)
DiagLogDataChunkKey_UserSystemClock = 9, ///< User system clock (unknown)
DiagLogDataChunkKey_ProcessName = 10 ///< Process name.
DiagLogDataChunkKey_LogSessionBegin = 0, ///< Log session begin (unknown)
DiagLogDataChunkKey_LogSessionEnd = 1, ///< Log session end (unknown)
DiagLogDataChunkKey_TextLog = 2, ///< Text to be logged.
DiagLogDataChunkKey_LineNumber = 3, ///< Source line number.
DiagLogDataChunkKey_FileName = 4, ///< Source file name.
DiagLogDataChunkKey_FunctionName = 5, ///< Source function name.
DiagLogDataChunkKey_ModuleName = 6, ///< Process module name.
DiagLogDataChunkKey_ThreadName = 7, ///< Process thread name.
DiagLogDataChunkKey_LogPacketDropCount = 8, ///< Log packet drop count (unknown)
DiagLogDataChunkKey_UserSystemClock = 9, ///< User system clock (unknown)
DiagLogDataChunkKey_ProcessName = 10, ///< Process name.
} DiagLogDataChunkKey;
/// DiagLogDataChunkTypeHeader (see specific types below)
typedef struct {
u8 chunk_key; ///< \ref DiagLogDataChunkKey
u8 chunk_len; ///< Value length.
u8 chunk_key; ///< \ref DiagLogDataChunkKey
u8 chunk_len; ///< Value length.
} DiagLogDataChunkTypeHeader;
// Specific chunk types.
@ -277,8 +277,8 @@ void diagLogImpl(const DiagLogMetadata *metadata) {
remaining_len -= cur_len;
}
size_t i = 0;
for(; i < packet_count; i++) {
size_t i;
for(i = 0; i < packet_count; i++) {
DiagLogPacket *cur_packet = &packets[i];
cur_packet->header.severity = (u8)metadata->severity;
cur_packet->header.verbosity = (u8)metadata->verbosity;