[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] certi/libCERTI PrettyDebug.hh PrettyDebug.cc
From: |
CERTI CVS commits |
Subject: |
[certi-cvs] certi/libCERTI PrettyDebug.hh PrettyDebug.cc |
Date: |
Thu, 21 Jun 2012 08:03:25 +0000 |
CVSROOT: /sources/certi
Module name: certi
Changes by: Eric NOULARD <erk> 12/06/21 08:03:25
Modified files:
libCERTI : PrettyDebug.hh PrettyDebug.cc
Log message:
Try to implement.
Trace in file
oen can now set CERTI_DEBUG_FILE env var
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/PrettyDebug.hh?cvsroot=certi&r1=4.8&r2=4.9
http://cvs.savannah.gnu.org/viewcvs/certi/libCERTI/PrettyDebug.cc?cvsroot=certi&r1=4.10&r2=4.11
Patches:
Index: PrettyDebug.hh
===================================================================
RCS file: /sources/certi/certi/libCERTI/PrettyDebug.hh,v
retrieving revision 4.8
retrieving revision 4.9
diff -u -b -r4.8 -r4.9
--- PrettyDebug.hh 21 Oct 2009 20:04:46 -0000 4.8
+++ PrettyDebug.hh 21 Jun 2012 08:03:24 -0000 4.9
@@ -19,7 +19,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
//
-// $Id: PrettyDebug.hh,v 4.8 2009/10/21 20:04:46 erk Exp $
+// $Id: PrettyDebug.hh,v 4.9 2012/06/21 08:03:24 erk Exp $
// ----------------------------------------------------------------------------
#ifndef PRETTYDEBUG_HH
@@ -32,6 +32,7 @@
#include "certi.hh"
#include <iosfwd>
#include <string>
+#include <fstream>
/** Do not use the pdUnused and pdLast Levels!!! Do not also specify
* any value for the elements, because order is used and missing
@@ -122,10 +123,11 @@
std::string _header;
std::ostream* _streams[pdLast];
+ static void initStreams();
static std::ostream _defaultOutputStream;
static std::string _federateName;
};
#endif // PRETTYDEBUG_HH
-// $Id: PrettyDebug.hh,v 4.8 2009/10/21 20:04:46 erk Exp $
+// $Id: PrettyDebug.hh,v 4.9 2012/06/21 08:03:24 erk Exp $
Index: PrettyDebug.cc
===================================================================
RCS file: /sources/certi/certi/libCERTI/PrettyDebug.cc,v
retrieving revision 4.10
retrieving revision 4.11
diff -u -b -r4.10 -r4.11
--- PrettyDebug.cc 21 Oct 2009 19:51:12 -0000 4.10
+++ PrettyDebug.cc 21 Jun 2012 08:03:25 -0000 4.11
@@ -19,12 +19,13 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
//
-// $Id: PrettyDebug.cc,v 4.10 2009/10/21 19:51:12 erk Exp $
+// $Id: PrettyDebug.cc,v 4.11 2012/06/21 08:03:25 erk Exp $
// ----------------------------------------------------------------------------
#include "PrettyDebug.hh"
#include <iostream>
+#include <fstream>
#include <iomanip>
#include <stdarg.h>
@@ -42,6 +43,21 @@
std::ostream PrettyDebug::_defaultOutputStream(std::cerr.rdbuf());
std::string PrettyDebug::_federateName;
+void PrettyDebug::initStreams() {
+ static std::filebuf* fb = NULL;
+ if (!fb) {
+ const char *value = getenv("CERTI_DEBUG_FILE");
+ if (value) {
+ fb = new std::filebuf();
+ fb->open(value, std::ios_base::out | std::ios_base::app);
+ }
+ }
+ /* replace buffer stream if we have one */
+ if (fb) {
+ _defaultOutputStream.rdbuf(fb);
+ }
+}
+
// ----------------------------------------------------------------------------
/** Constructor. Initialize the debug process according to the value
* of the 'name' environment variable. The 'header' message is put
@@ -49,11 +65,14 @@
* whatever you need. */
PrettyDebug::PrettyDebug(const char* name, const char* header)
{
+ PrettyDebug::initStreams();
+
if (header)
_header = header;
- for (unsigned i = pdUnused; i < unsigned(pdLast); ++i)
+ for (unsigned i = pdUnused; i < unsigned(pdLast); ++i) {
_streams[i] = 0;
+ }
// note that if we do not have a name, we cannot enable any debug message
...
if (name) {
@@ -65,11 +84,12 @@
unsigned valueLen = strlen(value);
for (unsigned i = 0; i < valueLen; ++i) {
const char* pos = strchr(debugKeys, value[i]);
- if (pos)
+ if (pos) {
_streams[pos - debugKeys] = &_defaultOutputStream;
}
}
}
+ }
}
// ----------------------------------------------------------------------------
@@ -176,4 +196,4 @@
return stream;
}
-// $Id: PrettyDebug.cc,v 4.10 2009/10/21 19:51:12 erk Exp $
+// $Id: PrettyDebug.cc,v 4.11 2012/06/21 08:03:25 erk Exp $
- [certi-cvs] certi/libCERTI PrettyDebug.hh PrettyDebug.cc,
CERTI CVS commits <=