Back to index

salome-kernel  6.5.0
Functions | Variables
DSC_interface.cxx File Reference
#include <string>
#include "DSC_interface.hxx"
#include <sys/time.h>
#include <fstream>
#include <sys/stat.h>
#include <sstream>
#include <stdlib.h>

Go to the source code of this file.

Functions

static void initTrace (const std::string &containerName)
 Initialize the trace file.

Variables

static int traceType = -1
static int traceLevel = -1
static std::ofstream traceFile
static std::ostream * out

Function Documentation

static void initTrace ( const std::string &  containerName) [static]

Initialize the trace file.

The trace file depends on an environment variable (DSC_TRACE). If this variable is equal to 1, the trace file is a file with the name : <TMPDIR>/<container name>="">.tce. In all other cases, the trace file is stderr The environment variable DSC_TRACELEVEL can be used to suppress the trace (value 0)

Parameters:
containerNamethe name of the container where the trace is built

Definition at line 413 of file DSC_interface.cxx.

{
  // if initialization has already been done do nothing
  if(traceLevel >= 0)return;

  std::string typeenv="0";
  std::string levelenv="1";
  char* valenv=0;
  valenv=getenv("DSC_TRACE");
  if(valenv)typeenv=valenv;
  valenv=getenv("DSC_TRACELEVEL");
  if(valenv)levelenv=valenv;

  if(levelenv=="0")
    traceLevel=0; // no trace
  else if(levelenv=="2")
    traceLevel=2; //detailed trace
  else
    traceLevel=1; // normal trace (default)

  if(traceLevel==0)
    return;

  if(typeenv=="1")
    {
      //trace in file
      traceType=1;
#ifdef WNT
      std::string logFilename=getenv("TEMP");
      logFilename += "\\";
#else
      std::string logFilename="/tmp";
      char* val = getenv("SALOME_TMP_DIR");
      if(val)
        {
          struct stat file_info;
          stat(val, &file_info);
          bool is_dir = S_ISDIR(file_info.st_mode);
          if (is_dir)logFilename=val;
        }
      logFilename += "/";
#endif

      logFilename=logFilename+containerName+".tce";
      traceFile.open(logFilename.c_str(), std::ios::out | std::ios::app);
      out=&traceFile;
    }
  else
    {
      //trace to stderr (default)
      traceType=0;
      out=&std::cerr;
    }
  //trace heading
  out->width(17);
  *out << "Elapsed time" ;
  *out << " | " ;
  out->width(16);
  *out << "Request" ;
  *out << " | " ;
  out->width(16);
  *out << "Container" ;
  *out << " | " ;
  out->width(16);
  *out << "Instance" ;
  *out << " | " ;
  out->width(16);
  *out << "Port" ;
  *out << " | " ;
  out->width(24);
  *out << "Error";
  *out << " | " ;
  *out << "Infos" ;
  *out << std::endl;
}

Here is the caller graph for this function:


Variable Documentation

std::ostream* out [static]

Definition at line 402 of file DSC_interface.cxx.

std::ofstream traceFile [static]

Definition at line 401 of file DSC_interface.cxx.

int traceLevel = -1 [static]

Definition at line 400 of file DSC_interface.cxx.

int traceType = -1 [static]

Definition at line 399 of file DSC_interface.cxx.