1
1

- Make opal_output_stream_t be a real opal_object_t so that it can use

a constructor, like the rest of the code base
- Convert usage in the tree to use the constructor to zero out an
  instance of opal_output_stream_t
- Still need to re-enable output files

This commit was SVN r7253.
Этот коммит содержится в:
Jeff Squyres 2005-09-09 10:46:54 +00:00
родитель 8ec6721f24
Коммит 4aa75fa739
7 изменённых файлов: 86 добавлений и 68 удалений

Просмотреть файл

@ -63,19 +63,7 @@ mca_btl_portals_component_t mca_btl_portals_component = {
};
static opal_output_stream_t portals_output_stream = {
true, /* is debugging */
0, /* verbose level */
0, /* want syslog */
0, /* syslog priority */
NULL, /* syslog ident */
NULL, /* prefix */
true, /* want stdout */
false, /* want stderr */
false, /* want file */
false, /* file append */
"btl-portals" /* file suffix */
};
static opal_output_stream_t portals_output_stream;
int
mca_btl_portals_component_open(void)
@ -88,6 +76,10 @@ mca_btl_portals_component_open(void)
*/
/* start up debugging output */
OBJ_CONSTRUCT(&portals_output_stream, opal_output_stream_t);
portals_output_stream.lds_is_debugging = true;
portals_output_stream.lds_want_stdout = true;
portals_output_stream.lds_file_suffix = "btl-portals";
mca_base_param_reg_int(&mca_btl_portals_component.super.btl_version,
"debug_level",
"Debugging verbosity (0 - 100)",

Просмотреть файл

@ -61,7 +61,8 @@ mca_ptl_portals_component_t mca_ptl_portals_component = {
};
static opal_output_stream_t portals_output_stream = {
static opal_output_stream_t portals_output_stream;
{
true, /* is debugging */
0, /* verbose level */
0, /* want syslog */
@ -121,6 +122,11 @@ mca_ptl_portals_component_open(void)
OBJ_CONSTRUCT(&mca_ptl_portals_component.portals_lock,
opal_mutex_t);
OBJ_CONSTRUCT(&portals_output_stream, opal_output_stream_t);
portals_output_stream.lds_is_debugging = true;
portals_output_stream.lds_want_stdout = true;
portals_output_stream.lds_file_suffix = "ptl-portals";
/* register portals module parameters */
#if PTL_PORTALS_UTCP
mca_ptl_portals_component.portals_ifname =
@ -203,7 +209,7 @@ mca_ptl_portals_component_close(void)
}
if (NULL != portals_output_stream.lds_prefix) {
free(portals_output_stream.lds_prefix);
portals_output_stream.lds_prefix = NULL;
}
opal_output_close(mca_ptl_portals_component.portals_output);

Просмотреть файл

@ -112,19 +112,12 @@ static void set_defaults(opal_output_stream_t *lds)
{
/* Load up defaults */
lds->lds_is_debugging = false;
lds->lds_verbose_level = 0;
lds->lds_want_syslog = false;
OBJ_CONSTRUCT(lds, opal_output_stream_t);
#ifndef WIN32
lds->lds_syslog_priority = LOG_INFO;
lds->lds_syslog_priority = LOG_INFO;
#endif
lds->lds_syslog_ident = "ompi";
lds->lds_want_stdout = false;
lds->lds_want_stderr = true;
lds->lds_want_file = false;
lds->lds_want_file_append = false;
lds->lds_file_suffix = NULL;
lds->lds_file_suffix = "mca.txt";
lds->lds_syslog_ident = "ompi";
lds->lds_want_stderr = true;
}
@ -137,8 +130,9 @@ static void parse_verbose(char *e, opal_output_stream_t *lds)
char *ptr, *next;
bool have_output = false;
if (NULL == e)
if (NULL == e) {
return;
}
edup = strdup(e);
ptr = edup;

Просмотреть файл

@ -49,29 +49,20 @@ int opal_malloc_output = -1;
/*
* Private variables
*/
static opal_output_stream_t malloc_stream = {
/* debugging */
true,
/* verbose level */
5,
/* syslog */
false, 0, NULL,
/* prefix */
"malloc_debug: ",
/* stdout */
false,
/* stderr */
true,
/* file */
false, false, NULL
};
static opal_output_stream_t malloc_stream;
/*
* Initialize the malloc debug interface
*/
void opal_malloc_init(void)
{
opal_malloc_output = opal_output_open(&malloc_stream);
OBJ_CONSTRUCT(&malloc_stream, opal_output_stream_t);
malloc_stream.lds_is_debugging = true;
malloc_stream.lds_verbose_level = 5;
malloc_stream.lds_prefix = "malloc debug: ";
malloc_stream.lds_want_stderr = true;
opal_malloc_output = opal_output_open(&malloc_stream);
}
@ -83,6 +74,7 @@ void opal_malloc_finalize(void)
if (-1 != opal_malloc_output) {
opal_output_close(opal_malloc_output);
opal_malloc_output = -1;
OBJ_DESTRUCT(&malloc_stream);
}
}

Просмотреть файл

@ -40,25 +40,13 @@
* Private data
*/
static int verbose_stream = -1;
static opal_output_stream_t verbose = {
/* debugging */
false,
/* verbose level */
0,
/* syslog */
false, 0, NULL, NULL,
/* stdout */
false,
/* stderr */
true,
/* file */
false, false, NULL
};
static opal_output_stream_t verbose;
/*
* Private functions
*/
static void construct(opal_object_t *stream);
static int do_open(int output_id, opal_output_stream_t * lds);
static int open_file(int i);
static void free_descriptor(int output_id);
@ -111,6 +99,8 @@ static opal_mutex_t mutex;
static bool syslog_opened = false;
OBJ_CLASS_INSTANCE(opal_output_stream_t, opal_object_t, construct, NULL);
/*
* Setup the output stream infrastructure
*/
@ -122,6 +112,9 @@ bool opal_output_init(void)
return true;
}
OBJ_CONSTRUCT(&verbose, opal_output_stream_t);
verbose.lds_want_stderr = true;
for (i = 0; i < OPAL_OUTPUT_MAX_STREAMS; ++i) {
info[i].ldi_used = false;
info[i].ldi_enabled = false;
@ -238,7 +231,7 @@ void opal_output_close(int output_id)
/* Setup */
if (!initialized) {
opal_output_init();
return;
}
/* If it's valid, used, enabled, and has an open file descriptor,
@ -273,6 +266,7 @@ void opal_output_close(int output_id)
temp_str = NULL;
temp_str_len = 0;
}
OBJ_DESTRUCT(&verbose);
OPAL_THREAD_UNLOCK(&mutex);
}
@ -328,6 +322,25 @@ void opal_output_finalize(void)
/************************************************************************/
/*
* Constructor
*/
static void construct(opal_object_t *obj)
{
opal_output_stream_t *stream = (opal_output_stream_t*) obj;
stream->lds_is_debugging = false;
stream->lds_verbose_level = 0;
stream->lds_want_syslog = false;
stream->lds_syslog_priority = 0;
stream->lds_syslog_ident = NULL;
stream->lds_prefix = NULL;
stream->lds_want_stdout = false;
stream->lds_want_file = false;
stream->lds_want_file_append = false;
stream->lds_file_suffix = NULL;
}
/*
* Back-end of open() and reopen(). Necessary to have it as a
* back-end function so that we can do the thread locking properly

Просмотреть файл

@ -63,6 +63,8 @@
#include <stdarg.h>
#include "opal/class/opal_object.h"
#if defined(c_plusplus) || defined(__cplusplus)
extern "C" {
#endif
@ -80,10 +82,11 @@ extern "C" {
* Note that all strings in this struct are cached on the stream by
* value; there is no need to keep them allocated after the return
* from opal_output_open().
*
* @see output.h
*/
struct opal_output_stream_t {
/** Class parent */
opal_object_t super;
/**
* Indicates whether the output of the stream is
* debugging/developer-only output or not.
@ -196,9 +199,20 @@ struct opal_output_stream_t {
*/
char *lds_file_suffix;
};
typedef struct opal_output_stream_t opal_output_stream_t;
/**
* Convenience typedef
*/
typedef struct opal_output_stream_t opal_output_stream_t;
/**
* Declare the class of this type. Note that the constructor for
* this class is for convenience only -- it is \em not necessary
* to be invoked. If the constructor it used, it sets all values
* in the struct to be false / 0 (i.e., turning off all output).
* The intended usage is to invoke the constructor and then enable
* the output fields that you want.
*/
OBJ_CLASS_DECLARATION(opal_output_stream_t);
/**
* Initializes the output stream system and opens a default

Просмотреть файл

@ -22,16 +22,22 @@
int opal_trace_handle;
/*
* Local state
*/
static opal_output_stream_t tracer;
void opal_trace_init(void)
{
#if OPAL_ENABLE_TRACE
opal_output_stream_t tracer;
/* get a file setup for opal_output to use for the trace */
tracer.lds_file_suffix = "trace";
tracer.lds_want_file = true;
/* get a file setup for opal_output to use for the trace */
OBJ_CONSTRUCT(&tracer, opal_output_stream_t);
tracer.lds_file_suffix = "trace";
tracer.lds_want_file = true;
opal_trace_handle = opal_output_open(&tracer);
opal_trace_handle = opal_output_open(&tracer);
#endif
}
@ -39,5 +45,6 @@ void opal_trace_finalize(void)
{
#if OPAL_ENABLE_TRACE
opal_output_close(opal_trace_handle);
OBJ_DESTRUCT(&tracer);
#endif
}