Skip to content
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

Change printf to PDC logger #232

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

TheAssembler1
Copy link
Collaborator

@TheAssembler1 TheAssembler1 commented Mar 20, 2025

This is a large commit but I think it is very beneficial for all logging to go through the PDC logger. This way we get the filename, function name, and line numbers for all logging.

Also removed large blocks of comments and changed the PDC logger to print the file name, function, and line number.

We can now remove a lot of the code that manually printed the line numbers for debugging and error identification reasons.

@TheAssembler1
Copy link
Collaborator Author

Still working on the clang-format I ran it on the codebase I'll look at what the cd/ci scripts do...

Also removed large blocks of comments and chanegd the pdc logger
to print the file name, function, and line number.
@@ -77,7 +77,7 @@ create_pdc_object(pdcid_t pdc_id, pdcid_t cont_id, const char *obj_name, pdc_var

pdcid_t obj_id = PDCobj_create_mpi(cont_id, obj_name, *obj_prop, 0, comm);
if (obj_id == 0) {
printf("Error getting an object id of %s from server, exit...\n", "obj-var-xx");
LOG_INFO("Error getting an object id of %s from server, exit...\n", "obj-var-xx");
Copy link
Member

Choose a reason for hiding this comment

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

LOG_ERROR or LOG_INFO?

@@ -142,7 +142,7 @@ main(int argc, char **argv)
for (i = 0; i < NUM_VARS; i++) {
ret = PDCreg_obtain_lock(obj_ids[i], region_remote_ids[i], PDC_WRITE, PDC_NOBLOCK);
if (ret != SUCCEED) {
printf("Fail to obtain lock @ line %d!\n", __LINE__);
LOG_INFO("Fail to obtain lock");
Copy link
Member

Choose a reason for hiding this comment

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

LOG_ERROR or LOG_INFO?

@@ -174,7 +174,7 @@ main(int argc, char **argv)
for (i = 0; i < NUM_VARS; i++) {
ret = PDCreg_release_lock(obj_ids[i], region_remote_ids[i], PDC_WRITE);
if (ret != SUCCEED) {
printf("Fail to release lock @ line %d!\n", __LINE__);
LOG_INFO("Fail to release lock");
Copy link
Member

Choose a reason for hiding this comment

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

LOG_ERROR or LOG_INFO? There are several similar ones in this file.

@@ -78,7 +78,7 @@ create_pdc_object(pdcid_t pdc_id, pdcid_t cont_id, const char *obj_name, pdc_var

pdcid_t obj_id = PDCobj_create_mpi(cont_id, obj_name, *obj_prop, 0, comm);
if (obj_id == 0) {
printf("Error getting an object id of %s from server, exit...\n", "obj-var-xx");
LOG_INFO("Error getting an object id of %s from server, exit...\n", "obj-var-xx");
Copy link
Member

Choose a reason for hiding this comment

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

LOG_ERROR or LOG_INFO?


if (!tif)
printf("tiff:threadError | File \"%s\" cannot be opened\n", fileName);
LGO_ERROR("tiff:threadError | File \"%s\" cannot be opened\n", fileName);
Copy link
Member

Choose a reason for hiding this comment

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

LGO_ERROR --> LOG_ERROR. This may be caught by compiler.

}

// close a container
if (PDCcont_close(cont) < 0) {
printf("fail to close container c1\n");
LOG_INFO("Fail to close container c1\n");
Copy link
Member

Choose a reason for hiding this comment

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

LOG_ERROR or LOG_INFO?


// close pdc
if (PDCclose(pdc) < 0) {
printf("fail to close PDC\n");
LOGI("fail to close PDC\n");
Copy link
Member

Choose a reason for hiding this comment

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

"failed to close PDC."

}
// close pdc
if (PDCclose(pdc) < 0) {
printf("fail to close PDC\n");
LOG_INFO("Fail to close PDC\n");
Copy link
Member

Choose a reason for hiding this comment

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

"Failed to close PDC"

ret_value = 1;
}
else {
printf("successfully close container property\n");
LOG_INFO("successfully close container property\n");
Copy link
Member

Choose a reason for hiding this comment

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

closed

}
// close a container property
if (PDCprop_close(cont_prop) < 0) {
printf("Fail to close property @ line %d\n", __LINE__);
LOG_INFO("Fail to close property");
Copy link
Member

Choose a reason for hiding this comment

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

Failed

ret_value = 1;
}
else {
printf("successfully close container c1\n");
LOG_INFO("successfully close container c1\n");
Copy link
Member

Choose a reason for hiding this comment

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

closed

@@ -129,26 +129,26 @@ main(int argc, char **argv)
// create a container property
cont_prop = PDCprop_create(PDC_CONT_CREATE, pdc);
if (cont_prop <= 0) {
printf("Fail to create container property @ line %d!\n", __LINE__);
LOG_INFO("Fail to create container property");
Copy link
Member

Choose a reason for hiding this comment

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

while we are at it, correct the grammar as well. "Failed"

Copy link
Member

@houjun houjun left a comment

Choose a reason for hiding this comment

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

@TheAssembler1 can you also add to the documentation about these new macros and how to use them? You can add a subsection in Developer Notes

@TheAssembler1
Copy link
Collaborator Author

@TheAssembler1 can you also add to the documentation about these new macros and how to use them? You can add a subsection in Developer Notes

I didn't create the logging macros they were already there just no one was using them. Yes I will add documentation for them.

@TheAssembler1
Copy link
Collaborator Author

@TheAssembler1 can you also add to the documentation about these new macros and how to use them? You can add a subsection in Developer Notes

Ok I added docs for each of the macros in the developer notes.

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