2005-09-07 22:52:28 +04:00
|
|
|
/* @file */
|
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2005-09-07 22:52:28 +04:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal_config.h"
|
2005-09-07 22:52:28 +04:00
|
|
|
#include "opal/util/output.h"
|
2005-09-09 22:27:17 +04:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
2005-09-07 22:52:28 +04:00
|
|
|
|
|
|
|
#include "opal/util/trace.h"
|
|
|
|
|
|
|
|
int opal_trace_handle;
|
|
|
|
|
2005-09-09 14:46:54 +04:00
|
|
|
/*
|
|
|
|
* Local state
|
|
|
|
*/
|
2005-09-10 15:17:01 +04:00
|
|
|
#if OPAL_ENABLE_TRACE
|
2005-09-09 14:46:54 +04:00
|
|
|
static opal_output_stream_t tracer;
|
2005-09-10 15:17:01 +04:00
|
|
|
#endif
|
2005-09-09 14:46:54 +04:00
|
|
|
|
|
|
|
|
2005-09-07 22:52:28 +04:00
|
|
|
void opal_trace_init(void)
|
|
|
|
{
|
2005-09-07 23:43:40 +04:00
|
|
|
#if OPAL_ENABLE_TRACE
|
2005-09-09 22:27:17 +04:00
|
|
|
int param, value;
|
2005-09-07 22:52:28 +04:00
|
|
|
|
2005-09-09 22:27:17 +04:00
|
|
|
param = mca_base_param_reg_int_name("trace", "verbose",
|
|
|
|
"Verbosity level for opal trace system",
|
|
|
|
false, false, 0, &value);
|
2005-09-07 22:52:28 +04:00
|
|
|
|
2005-09-09 22:27:17 +04:00
|
|
|
OBJ_CONSTRUCT(&tracer, opal_output_stream_t);
|
|
|
|
|
|
|
|
/* if the value is < 0, then we want the output to go to the screen */
|
|
|
|
if (0 > value) {
|
|
|
|
tracer.lds_want_file = false;
|
|
|
|
tracer.lds_want_stderr = true;
|
|
|
|
value = -1 * value;
|
|
|
|
} else if (0 == value) { /* don't provide any output */
|
|
|
|
opal_trace_handle = -1;
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
/* get a file setup for opal_output to use for the trace */
|
|
|
|
tracer.lds_file_suffix = "trace";
|
|
|
|
tracer.lds_want_file = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
tracer.lds_verbose_level = value;
|
|
|
|
|
|
|
|
opal_trace_handle = opal_output_open(&tracer);
|
2005-09-07 22:52:28 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void opal_trace_finalize(void)
|
|
|
|
{
|
2005-09-07 23:43:40 +04:00
|
|
|
#if OPAL_ENABLE_TRACE
|
2005-09-07 22:52:28 +04:00
|
|
|
opal_output_close(opal_trace_handle);
|
2005-09-09 14:46:54 +04:00
|
|
|
OBJ_DESTRUCT(&tracer);
|
2005-09-07 22:52:28 +04:00
|
|
|
#endif
|
|
|
|
}
|