Skip to content

control logger thru CTL #1446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

control logger thru CTL #1446

wants to merge 1 commit into from

Conversation

lplewa
Copy link
Contributor

@lplewa lplewa commented Jul 17, 2025

Description

Checklist

  • Code compiles without errors locally
  • All tests pass locally
  • CI workflows execute properly
  • CI workflows, not executed per PR (e.g. Nightly), execute properly
  • New tests added, especially if they will fail without my changes
  • Added/extended example(s) to cover this functionality
  • Extended the README/documentation
  • All newly added source files have a license
  • All newly added source files are referenced in CMake files
  • Logger (with debug/info/... messages) is used
  • All API changes are reflected in docs and def/map files, and are tested

@lplewa lplewa requested a review from a team as a code owner July 17, 2025 12:09
@lplewa lplewa force-pushed the ctl_logger branch 3 times, most recently from 0a0d049 to 777a17a Compare July 17, 2025 14:08
@@ -32,7 +33,7 @@ add_umf_library(
NAME umf_utils
TYPE STATIC
SRCS ${UMF_UTILS_SOURCES}
LIBS ${UMF_UTILS_LIBS} ${CMAKE_THREAD_LIBS_INIT})
LIBS ${UMF_UTILS_LIBS} ${CMAKE_THREAD_LIBS_INIT} umf_ba)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should avoid this if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for now, but please fill an issue to fix this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -61,14 +62,15 @@ char const __umf_str_1__all_cmake_vars[] =
#define MAX_ENV_LEN 2048

typedef struct {
int timestamp;
int pid;
bool timestamp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add comment "enable timestamp logging" or rename to enableTimestamp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

int timestamp;
int pid;
bool timestamp;
bool pid;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

} utils_log_config_t;

utils_log_config_t loggerConfig = {0, 0, LOG_ERROR, LOG_ERROR, NULL};
utils_log_config_t loggerConfig = {0, 0, LOG_ERROR, LOG_ERROR, NULL, NULL};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0, 0 -> false, false

}

if (loggerConfig.output == NULL) {
*arg_out = "logger_disabled";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just "disabled"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about "" ? is it different from NULL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will never be set to ""


TEST_F(test, ctl_logger_output_file) {
const char *file_name = "ctl_log.txt";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#include "test_helpers.h"
#include <umf/experimental/ctl.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move to the top (new section)

@@ -141,7 +143,7 @@ void helper_checkConfig(utils_log_config_t *expected, utils_log_config_t *is) {

TEST_F(test, parseEnv_errors) {
expected_message = "";
loggerConfig = {0, 0, LOG_ERROR, LOG_ERROR, NULL};
loggerConfig = {0, 0, LOG_ERROR, LOG_ERROR, NULL, ""};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool, bool?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -212,7 +214,8 @@ TEST_F(test, parseEnv) {
flushLevel.first + ";" +
output.first + ";" +
timestamp.first + ";" + pid.first;
b = loggerConfig = {0, 0, LOG_ERROR, LOG_ERROR, NULL};
b = loggerConfig = {0, 0, LOG_ERROR,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false, false here and in other places
btw why such weird formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,

clang format? who knows

const char *oldName =
loggerConfig.file_name ? loggerConfig.file_name : "disabled";

if (arg_in == NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about ""?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fopen will fail, and we will return an error for invalid argument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants