Skip to content

Request to direct SCR log messages to stderr or a custom file descriptor #541

@adammoody

Description

@adammoody

When running with SCR_DEBUG=1, SCR prints log messages to stdout. It would be useful at times to direct those messages to other files like stderr or perhaps a user-provided file descriptor. This would enable users to more easily filter SCR messages from their job logs.

The related code in SCR is in scr_err_mpi.c and scr_err_serial.c, e.g.:

scr/src/scr_err_mpi.c

Lines 52 to 63 in 48328f6

/* print message to stdout if scr_debug is set and it is >= level */
void scr_dbg(int level, const char *fmt, ...)
{
va_list argp;
if (level == 0 || (scr_debug > 0 && scr_debug >= level)) {
fprintf(stdout, "SCR %s: rank %d on %s: ", SCR_VERSION, scr_my_rank_world, scr_my_hostname);
va_start(argp, fmt);
vfprintf(stdout, fmt, argp);
va_end(argp);
fprintf(stdout, "\n");
}
}

There are a few other places where SCR calls print functions of other components, like:

scr/src/scr.c

Lines 1278 to 1289 in 48328f6

if (scr_debug > 0 && scr_my_rank_world == 0) {
scr_dbg(1, "Group descriptors:");
kvtree_print_mode(scr_groupdesc_hash, 4, KVTREE_PRINT_KEYVAL);
}
if (scr_debug > 0 && scr_my_rank_world == 0) {
scr_dbg(1, "Store descriptors:");
kvtree_print_mode(scr_storedesc_hash, 4, KVTREE_PRINT_KEYVAL);
}
if (scr_debug > 0 && scr_my_rank_world == 0) {
scr_dbg(1, "Redundancy descriptors:");
kvtree_print_mode(scr_reddesc_hash, 4, KVTREE_PRINT_KEYVAL);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions