feat(log): 支持设置多个日志级别的组合

将 `log_set_level` 函数的参数类型从 `log_level_t` 改为 `int`,
以支持传入多个日志级别的按位或组合。

同时调整测试代码中的日志级别设置方式,并修复部分逻辑引用问题,以及#未知宏跳过更多的行的bug。
This commit is contained in:
zzy
2025-11-20 14:30:14 +08:00
parent 47b56d52f6
commit 9762cf8a2b
4 changed files with 7 additions and 6 deletions

View File

@@ -375,7 +375,6 @@ static void parse_line(smcc_lexer_t* lexer, lexer_tok_t* token) {
lexer_next_pos(lexer);
if (ch != line[i]) {
LEX_WARN("Maroc does not support in lexer rather in preprocessor, it will be ignored");
skip_newline(lexer, token);
goto SKIP_LINE;
}
}

View File

@@ -23,7 +23,9 @@ int g_num_arr[3];
int main(int argc, char* argv[]) {
// int num = 0;
if (argc == 3 && strcmp(argv[2], "-nodebug") == 0) {
log_set_level(NULL, LOG_LEVEL_ALL);
log_set_level(NULL, LOG_LEVEL_INFO
| LOG_LEVEL_WARN
| LOG_LEVEL_ERROR);
}
const char* file_name = __FILE__;
@@ -63,7 +65,7 @@ int main(int argc, char* argv[]) {
core_stream_t* stream = core_mem_stream_init(&mem_stream, buffer, fsize, false);
Assert(stream != null);
cstring_clear(&stream->name);
cstring_push_cstr(&stream->name, __FILE__, strlen(__FILE__));
cstring_push_cstr(&stream->name, file_name, strlen(file_name));
lexer_init(&lexer, stream);
lexer_tok_t tok;
@@ -72,7 +74,7 @@ int main(int argc, char* argv[]) {
if (tok.type == TOKEN_EOF) {
break;
}
LOG_INFO("token `%s` at %s:%u:%u", get_tok_name(tok.type), tok.loc.name, tok.loc.line, tok.loc.column);
LOG_DEBUG("token `%s` at %s:%u:%u", get_tok_name(tok.type), tok.loc.name, tok.loc.line, tok.loc.column);
Assert(tok.loc.offset <= fsize);
// LOG_DEBUG("%s", tok.val.str);
// printf("line: %d, column: %d, type: %3d, typename: %s\n",