add logging to aggregators

This commit is contained in:
Tom Henderson
2013-08-11 20:53:01 -07:00
parent ce46777402
commit f2eaddb1c8
2 changed files with 68 additions and 26 deletions

View File

@@ -58,6 +58,8 @@ FileAggregator::FileAggregator (const std::string &outputFileName,
m_9dFormat ("%e %e %e %e %e %e %e %e %e"),
m_10dFormat ("%e %e %e %e %e %e %e %e %e %e")
{
NS_LOG_FUNCTION (this << outputFileName << fileType);
// Set the values separator.
switch (m_fileType)
{
@@ -73,25 +75,26 @@ FileAggregator::FileAggregator (const std::string &outputFileName,
break;
}
// Open the output file.
m_file.open (m_outputFileName.c_str ());
}
FileAggregator::~FileAggregator ()
{
// Close the output file.
NS_LOG_FUNCTION (this);
m_file.close ();
}
void
FileAggregator::SetFileType (enum FileType fileType)
{
NS_LOG_FUNCTION (this << fileType);
m_fileType = fileType;
}
void
FileAggregator::SetHeading (const std::string &heading)
{
NS_LOG_FUNCTION (this << heading);
if (!m_hasHeadingBeenSet)
{
m_heading = heading;
@@ -105,60 +108,70 @@ FileAggregator::SetHeading (const std::string &heading)
void
FileAggregator::Set1dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_1dFormat = format;
}
void
FileAggregator::Set2dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_2dFormat = format;
}
void
FileAggregator::Set3dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_3dFormat = format;
}
void
FileAggregator::Set4dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_4dFormat = format;
}
void
FileAggregator::Set5dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_5dFormat = format;
}
void
FileAggregator::Set6dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_6dFormat = format;
}
void
FileAggregator::Set7dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_7dFormat = format;
}
void
FileAggregator::Set8dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_8dFormat = format;
}
void
FileAggregator::Set9dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_9dFormat = format;
}
void
FileAggregator::Set10dFormat (const std::string &format)
{
NS_LOG_FUNCTION (this << format);
m_10dFormat = format;
}
@@ -166,6 +179,8 @@ void
FileAggregator::Write1d (std::string context,
double v1)
{
NS_LOG_FUNCTION (this << context << v1);
if (m_enabled)
{
// Write the 1D data point to the file.
@@ -203,6 +218,8 @@ FileAggregator::Write2d (std::string context,
double v1,
double v2)
{
NS_LOG_FUNCTION (this << context << v1 << v2);
if (m_enabled)
{
// Write the 2D data point to the file.
@@ -243,6 +260,8 @@ FileAggregator::Write3d (std::string context,
double v2,
double v3)
{
NS_LOG_FUNCTION (this << context << v1 << v2 << v3);
if (m_enabled)
{
// Write the 3D data point to the file.
@@ -286,6 +305,8 @@ FileAggregator::Write4d (std::string context,
double v3,
double v4)
{
NS_LOG_FUNCTION (this << context << v1 << v2 << v3 << v4);
if (m_enabled)
{
// Write the 4D data point to the file.
@@ -332,6 +353,8 @@ FileAggregator::Write5d (std::string context,
double v4,
double v5)
{
NS_LOG_FUNCTION (this << context << v1 << v2 << v3 << v4 << v5);
if (m_enabled)
{
// Write the 5D data point to the file.
@@ -381,6 +404,8 @@ FileAggregator::Write6d (std::string context,
double v5,
double v6)
{
NS_LOG_FUNCTION (this << context << v1 << v2 << v3 << v4 << v5 << v6);
if (m_enabled)
{
// Write the 6D data point to the file.
@@ -433,6 +458,8 @@ FileAggregator::Write7d (std::string context,
double v6,
double v7)
{
NS_LOG_FUNCTION (this << context << v1 << v2 << v3 << v4 << v5 << v6 << v7);
if (m_enabled)
{
// Write the 7D data point to the file.
@@ -488,6 +515,8 @@ FileAggregator::Write8d (std::string context,
double v7,
double v8)
{
NS_LOG_FUNCTION (this << context << v1 << v2 << v3 << v4 << v5 << v6 << v7 << v8);
if (m_enabled)
{
// Write the 8D data point to the file.
@@ -546,6 +575,7 @@ FileAggregator::Write9d (std::string context,
double v8,
double v9)
{
NS_LOG_FUNCTION (this << context << v1 << v2 << v3 << v4 << v5 << v6 << v7 << v8 << v9);
if (m_enabled)
{
// Write the 9D data point to the file.
@@ -607,6 +637,7 @@ FileAggregator::Write10d (std::string context,
double v9,
double v10)
{
NS_LOG_FUNCTION (this << context << v1 << v2 << v3 << v4 << v5 << v6 << v7 << v8 << v9 << v10);
if (m_enabled)
{
// Write the 10D data point to the file.

View File

@@ -51,18 +51,19 @@ GnuplotAggregator::GnuplotAggregator (const std::string &outputFileNameWithoutEx
m_xAndYLegendsSet (false),
m_gnuplot (m_graphicsFileName)
{
NS_LOG_FUNCTION (this);
}
GnuplotAggregator::~GnuplotAggregator ()
{
// Give any warnings that should be issued.
NS_LOG_FUNCTION (this);
if (!m_titleSet)
{
NS_LOG_UNCOND ("Warning: The plot title was not set for the gnuplot aggregator");
NS_LOG_WARN ("Warning: The plot title was not set for the gnuplot aggregator");
}
if (!m_xAndYLegendsSet)
{
NS_LOG_UNCOND ("Warning: The axis legends were not set for the gnuplot aggregator");
NS_LOG_WARN ("Warning: The axis legends were not set for the gnuplot aggregator");
}
std::string dataFileName = m_outputFileNameWithoutExtension + ".dat";
@@ -101,10 +102,11 @@ GnuplotAggregator::~GnuplotAggregator ()
void
GnuplotAggregator::Write2d (std::string context, double x, double y)
{
NS_LOG_FUNCTION (this << context << x << y);
if (m_2dDatasetMap.count (context) == 0)
{
NS_ABORT_MSG ("That 2D data set has not been added");
return;
NS_ABORT_MSG ("Dataset " << context << " has not been added");
}
if (m_enabled)
@@ -120,11 +122,11 @@ GnuplotAggregator::Write2dWithXErrorDelta (std::string context,
double y,
double errorDelta)
{
// See if this dataset has been added.
NS_LOG_FUNCTION (this << context << x << y << errorDelta);
if (m_2dDatasetMap.count (context) == 0)
{
NS_ABORT_MSG ("That 2D data set has not been added");
return;
NS_ABORT_MSG ("Dataset " << context << " has not been added");
}
if (m_enabled)
@@ -140,11 +142,11 @@ GnuplotAggregator::Write2dWithYErrorDelta (std::string context,
double y,
double errorDelta)
{
// See if this dataset has been added.
NS_LOG_FUNCTION (this << context << x << y << errorDelta);
if (m_2dDatasetMap.count (context) == 0)
{
NS_ABORT_MSG ("That 2D data set has not been added");
return;
NS_ABORT_MSG ("Dataset " << context << " has not been added");
}
if (m_enabled)
@@ -161,11 +163,11 @@ GnuplotAggregator::Write2dWithXYErrorDelta (std::string context,
double xErrorDelta,
double yErrorDelta)
{
// See if this dataset has been added.
NS_LOG_FUNCTION (this << context << x << y << xErrorDelta << yErrorDelta);
if (m_2dDatasetMap.count (context) == 0)
{
NS_ABORT_MSG ("That 2D data set has not been added");
return;
NS_ABORT_MSG ("Dataset " << context << " has not been added");
}
if (m_enabled)
@@ -189,6 +191,7 @@ GnuplotAggregator::SetTerminal (const std::string &terminal)
void
GnuplotAggregator::SetTitle (const std::string &title)
{
NS_LOG_FUNCTION (this << title);
m_gnuplot.SetTitle (title);
m_titleSet = true;
}
@@ -196,6 +199,7 @@ GnuplotAggregator::SetTitle (const std::string &title)
void
GnuplotAggregator::SetLegend (const std::string &xLegend, const std::string &yLegend)
{
NS_LOG_FUNCTION (this << xLegend << yLegend);
m_gnuplot.SetLegend (xLegend, yLegend);
m_xAndYLegendsSet = true;
}
@@ -203,22 +207,25 @@ GnuplotAggregator::SetLegend (const std::string &xLegend, const std::string &yLe
void
GnuplotAggregator::SetExtra (const std::string &extra)
{
NS_LOG_FUNCTION (this << extra);
m_gnuplot.SetExtra (extra);
}
void
GnuplotAggregator::AppendExtra (const std::string &extra)
{
NS_LOG_FUNCTION (this << extra);
m_gnuplot.AppendExtra (extra);
}
void
GnuplotAggregator::Add2dDataset (const std::string &dataset, const std::string &title)
{
// See if this dataset had already been added.
NS_LOG_FUNCTION (this << dataset << title);
if (m_2dDatasetMap.count (dataset) > 0)
{
NS_ABORT_MSG ("That 2D data set has already been added");
NS_ABORT_MSG ("Dataset " << dataset << " has already been added");
}
// Add this dataset to the map so that its values can be saved.
@@ -232,16 +239,17 @@ GnuplotAggregator::Add2dDataset (const std::string &dataset, const std::string &
void
GnuplotAggregator::Set2dDatasetDefaultExtra (const std::string &extra)
{
NS_LOG_FUNCTION (extra);
Gnuplot2dDataset::SetDefaultExtra (extra);
}
void
GnuplotAggregator::Set2dDatasetExtra (const std::string &dataset, const std::string &extra)
{
NS_LOG_FUNCTION (this << dataset << extra);
if (m_2dDatasetMap.count (dataset) == 0)
{
NS_ABORT_MSG ("That 2D data set has not been added");
return;
NS_ABORT_MSG ("Dataset " << dataset << " has not been added");
}
// Set the extra parameters for the dataset.
@@ -251,10 +259,10 @@ GnuplotAggregator::Set2dDatasetExtra (const std::string &dataset, const std::str
void
GnuplotAggregator::Write2dDatasetEmptyLine (const std::string &dataset)
{
NS_LOG_FUNCTION (this << dataset);
if (m_2dDatasetMap.count (dataset) == 0)
{
NS_ABORT_MSG ("That 2D data set has not been added");
return;
NS_ABORT_MSG ("Dataset " << dataset << " has not been added");
}
if (m_enabled)
@@ -267,16 +275,17 @@ GnuplotAggregator::Write2dDatasetEmptyLine (const std::string &dataset)
void
GnuplotAggregator::Set2dDatasetDefaultStyle (enum Gnuplot2dDataset::Style style)
{
NS_LOG_FUNCTION (style);
Gnuplot2dDataset::SetDefaultStyle (style);
}
void
GnuplotAggregator::Set2dDatasetStyle (const std::string &dataset, enum Gnuplot2dDataset::Style style)
{
NS_LOG_FUNCTION (this << dataset << style);
if (m_2dDatasetMap.count (dataset) == 0)
{
NS_ABORT_MSG ("That 2D data set has not been added");
return;
NS_ABORT_MSG ("Dataset " << dataset << " has not been added");
}
// Set the style for the dataset.
@@ -286,16 +295,17 @@ GnuplotAggregator::Set2dDatasetStyle (const std::string &dataset, enum Gnuplot2d
void
GnuplotAggregator::Set2dDatasetDefaultErrorBars (enum Gnuplot2dDataset::ErrorBars errorBars)
{
NS_LOG_FUNCTION (errorBars);
Gnuplot2dDataset::SetDefaultErrorBars (errorBars);
}
void
GnuplotAggregator::Set2dDatasetErrorBars (const std::string &dataset, enum Gnuplot2dDataset::ErrorBars errorBars)
{
NS_LOG_FUNCTION (this << dataset << errorBars);
if (m_2dDatasetMap.count (dataset) == 0)
{
NS_ABORT_MSG ("That 2D data set has not been added");
return;
NS_ABORT_MSG ("Dataset " << dataset << " has not been added");
}
// Set the error bars for the dataset.
@@ -305,6 +315,7 @@ GnuplotAggregator::Set2dDatasetErrorBars (const std::string &dataset, enum Gnupl
void
GnuplotAggregator::SetKeyLocation (enum GnuplotAggregator::KeyLocation keyLocation)
{
NS_LOG_FUNCTION (this << keyLocation);
// Set the specifed key location.
switch (keyLocation)
{