-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
156 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Release Notes | ||
|
||
| date | version | | ||
| ---- | ---- | | ||
| 2024-01-11 | v0.1.5 | | ||
| 2024-01-13 | v0.1.6 | | ||
| 2024-03-22 | v0.2.0 | | ||
| 2024-08-21 | v0.3.0 | | ||
| 2024-09-05 | v0.3.1 | | ||
|
||
--- | ||
## v0.3.1 | ||
* fix: long log line overflow | ||
|
||
--- | ||
## v0.3.0 | ||
* update: allow to disable thread context auto initialize | ||
|
||
--- | ||
## v0.2.0 | ||
* update: support callback function before backend run | ||
|
||
--- | ||
## v0.1.6 | ||
* update: hint non-standard(c11) '%lf' specifier | ||
* fix: serialize '%%' | ||
|
||
--- | ||
## v0.1.5 | ||
* fix: haclog context init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#include "haclog/haclog.h" | ||
#include "unity.h" | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <stdlib.h> | ||
|
||
#define LINE_SIZE 8 | ||
#define FILE_PATH "logs/test_long_message.log" | ||
|
||
void setUp() | ||
{ | ||
} | ||
|
||
void tearDown() | ||
{ | ||
} | ||
|
||
int my_write_meta(struct haclog_handler *handler, haclog_meta_info_t *meta) | ||
{ | ||
// do nothing | ||
HACLOG_UNUSED(handler); | ||
HACLOG_UNUSED(meta); | ||
return 0; | ||
} | ||
|
||
void add_console_handler() | ||
{ | ||
static haclog_console_handler_t handler; | ||
memset(&handler, 0, sizeof(handler)); | ||
if (haclog_console_handler_init(&handler, 1) != 0) { | ||
fprintf(stderr, "failed init console handler"); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
haclog_handler_set_level((haclog_handler_t *)&handler, HACLOG_LEVEL_INFO); | ||
haclog_handler_set_fn_write_meta((haclog_handler_t *)&handler, | ||
my_write_meta); | ||
haclog_context_add_handler((haclog_handler_t *)&handler); | ||
} | ||
|
||
void add_file_handler() | ||
{ | ||
static haclog_file_handler_t handler; | ||
memset(&handler, 0, sizeof(handler)); | ||
if (haclog_file_handler_init(&handler, FILE_PATH, "w") != 0) { | ||
fprintf(stderr, "failed init file handler"); | ||
exit(EXIT_FAILURE); | ||
} | ||
haclog_handler_set_level((haclog_handler_t *)&handler, HACLOG_LEVEL_DEBUG); | ||
haclog_handler_set_fn_write_meta((haclog_handler_t *)&handler, | ||
my_write_meta); | ||
haclog_context_add_handler((haclog_handler_t *)&handler); | ||
} | ||
|
||
void write_log() | ||
{ | ||
add_console_handler(); | ||
add_file_handler(); | ||
haclog_backend_run(); | ||
|
||
haclog_context_set_msg_buf_size(LINE_SIZE); | ||
char buf[LINE_SIZE * 2]; | ||
for (int i = 0; i < LINE_SIZE * 2 - 1; ++i) { | ||
buf[i] = '0'; | ||
} | ||
buf[LINE_SIZE * 2 - 1] = '\0'; | ||
|
||
haclog_thread_context_init(); | ||
|
||
HACLOG_INFO("%s", buf); | ||
|
||
haclog_thread_context_cleanup(); | ||
} | ||
|
||
void test_long_message() | ||
{ | ||
write_log(); | ||
|
||
FILE *fp = fopen(FILE_PATH, "rb"); | ||
fseek(fp, 0L, SEEK_END); | ||
long n = ftell(fp); | ||
fclose(fp); | ||
|
||
#if HACLOG_PLATFORM_WINDOWS | ||
// NOTE: in windows, new line is '\r''\n' | ||
TEST_ASSERT_TRUE(n - 1 <= LINE_SIZE); | ||
#else | ||
TEST_ASSERT_TRUE(n <= LINE_SIZE); | ||
#endif | ||
} | ||
|
||
int main() | ||
{ | ||
UNITY_BEGIN(); | ||
|
||
RUN_TEST(test_long_message); | ||
|
||
return UNITY_END(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.3.0 | ||
0.3.1 |