Skip to content

Commit

Permalink
common: several fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
grom72 committed Feb 22, 2024
1 parent 0b3b5db commit 426d6f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 0 additions & 4 deletions src/core/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ core_log_va(char *buf, size_t buf_len, enum core_log_level level,
goto end;
}

if (Core_log_function != (uintptr_t)core_log_default_function &&
level == CORE_LOG_LEVEL_ALWAYS)
level = CORE_LOG_LEVEL_NOTICE;

((core_log_function *)Core_log_function)(Core_log_function_context,
level, file_name, line_no, function_name, buf);

Expand Down
4 changes: 3 additions & 1 deletion src/libpmemobj/obj_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ pmemobj_log_get_threshold(enum pmemobj_log_threshold threshold,
int
pmemobj_log_set_function(pmemobj_log_function *log_function, void *context)
{
if (log_function == PMEMOBJ_LOG_USE_DEFAULT_FUNCTION)
if (log_function == PMEMOBJ_LOG_USE_DEFAULT_FUNCTION) {
context = NULL;
log_function = CORE_LOG_USE_DEFAULT_FUNCTION;
}

int ret = core_log_set_function((core_log_function *)log_function,
context);
Expand Down
11 changes: 5 additions & 6 deletions src/test/core_log/core_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ test_CORE_LOG_BASIC(const struct test_case *tc, int argc, char *argv[])
TEST_STEP(ERROR);
TEST_STEP(WARNING);
TEST_STEP(NOTICE);
context.line_no = __LINE__; CORE_LOG_ALWAYS(CORE_LOG_UT_MESSAGE);
context.line_no = __LINE__; CORE_LOG_HARK(CORE_LOG_UT_MESSAGE);
UT_ASSERTeq(Log_function_no_of_calls, 5);
UT_ASSERTeq(Core_log_abort_no_of_calls, 1);
return NO_ARGS_CONSUMED;
Expand All @@ -182,7 +182,7 @@ test_CORE_LOG_BASIC_LONG(const struct test_case *tc, int argc, char *argv[])
TEST_STEP_LONG(WARNING);
TEST_STEP_LONG(NOTICE);
context.line_no = __LINE__ + 1;
CORE_LOG_ALWAYS(CORE_LOG_UT_MESSAGE_LONG);
CORE_LOG_HARK(CORE_LOG_UT_MESSAGE_LONG);
UT_ASSERTeq(Log_function_no_of_calls, 5);
UT_ASSERTeq(Core_log_abort_no_of_calls, 1);
return NO_ARGS_CONSUMED;
Expand Down Expand Up @@ -292,7 +292,7 @@ test_CORE_LOG_BASIC_W_ERRNO_BAD(const struct test_case *tc, int argc,
CORE_LOG_TRESHOLD_STEP(CORE_LOG_ERROR, 0, _es, _es); \
CORE_LOG_TRESHOLD_STEP(CORE_LOG_WARNING, 0, _ws, _we); \
CORE_LOG_TRESHOLD_STEP(CORE_LOG_NOTICE, 0, _ns, _ne); \
CORE_LOG_TRESHOLD_STEP(CORE_LOG_ALWAYS, 0, _as, 0);
CORE_LOG_TRESHOLD_STEP(CORE_LOG_HARK, 0, _as, 0);

static int
test_CORE_LOG_TRESHOLD(const struct test_case *tc, int argc, char *argv[])
Expand All @@ -304,16 +304,15 @@ test_CORE_LOG_TRESHOLD(const struct test_case *tc, int argc, char *argv[])
CORE_LOG_TRESHOLD_STEP(CORE_LOG_ERROR, 0, 1, 1);
CORE_LOG_TRESHOLD_STEP(CORE_LOG_WARNING, 0, 1, 1);
CORE_LOG_TRESHOLD_STEP(CORE_LOG_NOTICE, 0, 1, 0);
CORE_LOG_TRESHOLD_STEP(CORE_LOG_ALWAYS, 0, 1, 0);
core_log_set_threshold(CORE_LOG_THRESHOLD, CORE_LOG_DISABLED);
CORE_LOG_TRESHOLD_STEP(CORE_LOG_HARK, 0, 1, 0);
core_log_set_threshold(CORE_LOG_THRESHOLD, CORE_LOG_LEVEL_HARK);
CORE_LOG_TRESHOLD_STEP_ALL(0, 0, 0, 0, 0, 0, 0, 0, 1);
core_log_set_threshold(CORE_LOG_THRESHOLD, CORE_LOG_LEVEL_FATAL);
CORE_LOG_TRESHOLD_STEP_ALL(1, 1, 0, 0, 0, 0, 0, 0, 1);
core_log_set_threshold(CORE_LOG_THRESHOLD, CORE_LOG_LEVEL_ERROR);
CORE_LOG_TRESHOLD_STEP_ALL(1, 1, 1, 1, 0, 0, 0, 0, 1);
core_log_set_threshold(CORE_LOG_THRESHOLD, CORE_LOG_LEVEL_WARNING);
CORE_LOG_TRESHOLD_STEP_ALL(1, 1, 1, 1, 1, 1, 0, 0, 1);
UT_OUT("DDDD");
core_log_set_threshold(CORE_LOG_THRESHOLD, CORE_LOG_LEVEL_NOTICE);
CORE_LOG_TRESHOLD_STEP_ALL(1, 1, 1, 1, 1, 1, 1, 0, 1);
return NO_ARGS_CONSUMED;
Expand Down

0 comments on commit 426d6f3

Please sign in to comment.