Compare commits

...

2 Commits

Author SHA1 Message Date
falsycat 9c439416bd remove description with mistakes 2024-02-15 13:35:49 +09:00
falsycat eaaad38fac fix issues 2024-02-15 13:34:06 +09:00
4 changed files with 11 additions and 31 deletions

View File

@ -13,29 +13,6 @@ ALLCING is a structured logging library featuring on lightweightness.
- compact log data with simple binary format
- completely-free license (WTFPLv2)
# Log Data Format
```
# [TOKEN] means TOKEN is optional
# <TOKEN> means TOKEN is constant and refer allcing.h for actual value
ROOT := CHUNK_BEGIN | CHUNK_END | CHUNK_CHECK
CHUNK_BEGIN := <ACG_CHUNK_BEGIN> [CHUNK_DATA]
CHUNK_END := <ACG_CHUNK_END> [CHUNK_DATA]
CHUNK_CHECK := <ACG_CHUNK_CHECK> [CHUNK_DATA]
CHUNK_DATA := CHUNK_PAD | CHUNK_BLOB | CHUNK_CTX | CHUNK_LOC | CHUNK_DATA
CHUNK_PAD := <ACG_CHUNK_PAD> PAD
CHUNK_BLOB := <ACG_CHUNK_BLOB> BLOB
CHUNK_CTX := <ACG_CHUNK_CTX> UINT(64) UINT(16)
CHUNK_LOC := <ACG_CHUNK_LOC> BLOB
PAD :=
BLOB :=
UINT(x) :=
```
# License
Do What The Fuck You Want to Public License v2

View File

@ -21,7 +21,7 @@
# define ACG_TID (0x700FU) // you should replace ACG_TID to log an actual TID
#endif
#if !defined(ACG_LOC_FULL)
# define ACG_LOC_FULL (__FILE__ ":" ACG_UTIL_STR2(__func__) ":" ACG_UTIL_STR2(__LINE__))
# define ACG_LOC_FULL (__FILE__ ":" ACG_UTIL_STR2(__LINE__))
#endif
#if !defined(ACG_LOC_SHORT)
# define ACG_LOC_SHORT ACG_UTIL_STR2(__LINE__)
@ -48,7 +48,7 @@
)
#define ACG_END(s) ( \
acg_stream_write_chunk_end((s)) && \
acg_stream_write_chunk_loc((s), sizeof(ACG_LOC_FULL)-1U,(const uint8_t*) ACG_LOC_FULL) && \
acg_stream_write_chunk_loc((s), sizeof(ACG_LOC_SHORT)-1U,(const uint8_t*) ACG_LOC_SHORT) && \
acg_stream_write_chunk_ctx((s), ACG_NOW, ACG_TID) && \
ACG_FLUSH((s)) \
)
@ -188,7 +188,7 @@ static inline bool acg_stream_write_chunk_ctx(struct acg_stream* s, uint64_t tim
assert(NULL != s);
return
acg_stream_write_uint(s, ACG_CHUNK_CTX, ACG_UNITBITS_CHUNK_ID) &&
acg_stream_write_uint(s, time, 64U) &&
acg_stream_write_uint(s, time, 32U) &&
acg_stream_write_uint(s, tid, 16U);
}
static inline bool acg_stream_write_chunk_loc(struct acg_stream* s, uint64_t size_bytes, const uint8_t* buf) {

View File

@ -11,7 +11,6 @@
static inline bool acg_stream_flush(struct acg_stream* s) {
assert(NULL != s);
acg_stream_write_chunk_pad(s);
if (s->cursor_bits < 8U) {
return false;
}
@ -42,8 +41,6 @@ static inline bool acg_stream_flush(struct acg_stream* s) {
}
return true;
}
#undef ACG_LOC_FULL
#define ACG_LOC_FULL ACG_LOC_SHORT
#undef ACG_FLUSH
#define ACG_FLUSH(s) acg_stream_flush((s))

View File

@ -86,11 +86,17 @@ int main(int argc, char** argv) {
fprintf(stderr, "failed to read BLOB in BLOB chunk\n");
return EXIT_FAILURE;
}
INDENT_PRINT("-BLOB: %.*s", (int) size, (const char*) buf);
if (size <= 8U) {
uint64_t v = 0U;
memcpy(&v, buf, size);
INDENT_PRINT("-BLOB: 0x%" PRIu64 " (size:%" PRIu64 ")", v, size);
} else {
INDENT_PRINT("-BLOB: %.*s", (int) size, (const char*) buf);
}
} break;
case ACG_CHUNK_CTX: {
uint64_t time;
if (!acg_stream_read_uint(&s, &time, 64U)) {
if (!acg_stream_read_uint(&s, &time, 32U)) {
fprintf(stderr, "failed to read TIME in CTX chunk\n");
return EXIT_FAILURE;
}