Add a default prefix to stream 0 ("[hostname:pid]") to help identify
where output is coming from. Threw in a few minor style fixes while I was editing these files. This commit was SVN r7522.
Этот коммит содержится в:
родитель
09e67ce4fd
Коммит
26efa2c4cd
@ -14,14 +14,16 @@
|
|||||||
* $HEADER$
|
* $HEADER$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "ompi_config.h"
|
#include "ompi_config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if HAVE_SYSLOG_H
|
#if HAVE_SYSLOG_H
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if HAVE_UNISTD_H
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "opal/util/output.h"
|
#include "opal/util/output.h"
|
||||||
#include "opal/util/printf.h"
|
#include "opal/util/printf.h"
|
||||||
@ -51,6 +53,7 @@ int mca_base_open(void)
|
|||||||
int param_index;
|
int param_index;
|
||||||
char *value;
|
char *value;
|
||||||
opal_output_stream_t lds;
|
opal_output_stream_t lds;
|
||||||
|
char hostname[64];
|
||||||
|
|
||||||
if (!mca_base_opened) {
|
if (!mca_base_opened) {
|
||||||
mca_base_opened = true;
|
mca_base_opened = true;
|
||||||
@ -96,6 +99,8 @@ int mca_base_open(void)
|
|||||||
} else {
|
} else {
|
||||||
set_defaults(&lds);
|
set_defaults(&lds);
|
||||||
}
|
}
|
||||||
|
gethostname(hostname, sizeof(hostname));
|
||||||
|
asprintf(&lds.lds_prefix, "[%s:%05d] ", hostname, getpid());
|
||||||
opal_output_reopen(0, &lds);
|
opal_output_reopen(0, &lds);
|
||||||
opal_output_verbose(5, 0, "mca: base: opening components");
|
opal_output_verbose(5, 0, "mca: base: opening components");
|
||||||
|
|
||||||
@ -110,7 +115,8 @@ int mca_base_open(void)
|
|||||||
*/
|
*/
|
||||||
static void set_defaults(opal_output_stream_t *lds)
|
static void set_defaults(opal_output_stream_t *lds)
|
||||||
{
|
{
|
||||||
/* Load up defaults */
|
|
||||||
|
/* Load up defaults */
|
||||||
|
|
||||||
OBJ_CONSTRUCT(lds, opal_output_stream_t);
|
OBJ_CONSTRUCT(lds, opal_output_stream_t);
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@ -141,9 +147,9 @@ static void parse_verbose(char *e, opal_output_stream_t *lds)
|
|||||||
|
|
||||||
while (NULL != ptr && strlen(ptr) > 0) {
|
while (NULL != ptr && strlen(ptr) > 0) {
|
||||||
next = strchr(ptr, ',');
|
next = strchr(ptr, ',');
|
||||||
if (NULL != next)
|
if (NULL != next) {
|
||||||
*next = '\0';
|
*next = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
if (0 == strcasecmp(ptr, "syslog")) {
|
if (0 == strcasecmp(ptr, "syslog")) {
|
||||||
#ifndef WIN32 /* there is no syslog */
|
#ifndef WIN32 /* there is no syslog */
|
||||||
@ -163,7 +169,7 @@ static void parse_verbose(char *e, opal_output_stream_t *lds)
|
|||||||
lds->lds_want_syslog = true;
|
lds->lds_want_syslog = true;
|
||||||
lds->lds_syslog_ident = ptr + 9;
|
lds->lds_syslog_ident = ptr + 9;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (strcasecmp(ptr, "stdout") == 0) {
|
else if (strcasecmp(ptr, "stdout") == 0) {
|
||||||
lds->lds_want_stdout = true;
|
lds->lds_want_stdout = true;
|
||||||
@ -192,8 +198,9 @@ static void parse_verbose(char *e, opal_output_stream_t *lds)
|
|||||||
lds->lds_verbose_level = atoi(ptr + 6);
|
lds->lds_verbose_level = atoi(ptr + 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == next)
|
if (NULL == next) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
ptr = next + 1;
|
ptr = next + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,13 +110,16 @@ bool opal_output_init(void)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *str;
|
char *str;
|
||||||
|
char hostname[32];
|
||||||
|
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
OBJ_CONSTRUCT(&verbose, opal_output_stream_t);
|
OBJ_CONSTRUCT(&verbose, opal_output_stream_t);
|
||||||
|
gethostname(hostname, sizeof(hostname));
|
||||||
verbose.lds_want_stderr = true;
|
verbose.lds_want_stderr = true;
|
||||||
|
asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid());
|
||||||
|
|
||||||
for (i = 0; i < OPAL_OUTPUT_MAX_STREAMS; ++i) {
|
for (i = 0; i < OPAL_OUTPUT_MAX_STREAMS; ++i) {
|
||||||
info[i].ldi_used = false;
|
info[i].ldi_used = false;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user