From 57ab5a216fd96373b40eb03c50b46366a4784f5b Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Thu, 2 Jul 2015 11:28:25 +0200 Subject: [PATCH] Enhance logging. --- src/ctbin/ctbin.cpp | 33 ++++++++++++++++++--------------- src/ctobssim/ctobssim.cpp | 19 +++++++++---------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/ctbin/ctbin.cpp b/src/ctbin/ctbin.cpp index 5b875c0..221491d 100644 --- a/src/ctbin/ctbin.cpp +++ b/src/ctbin/ctbin.cpp @@ -241,15 +241,27 @@ void ctbin::run(void) // Loop over all observations in the container for (int i = 0; i < m_obs.size(); ++i) { + // Write header for observation + if (logTerse()) { + std::string header = m_obs[i]->instrument() + " observation"; + if (m_obs[i]->name().length() > 1) { + header += " \"" + m_obs[i]->name() + "\""; + } + if (m_obs[i]->id().length() > 1) { + header += " (id=" + m_obs[i]->id() +")"; + } + log.header3(header); + } + // Get CTA observation GCTAObservation* obs = dynamic_cast(m_obs[i]); // Skip observation if it's not CTA if (obs == NULL) { if (logTerse()) { - log << "Warning: Skipping "+m_obs[i]->instrument(); - log << " observation \""; - log << m_obs[i]->name() << "\"" << std::endl; + log << " Skipping "; + log << m_obs[i]->instrument(); + log << " observation" << std::endl; } continue; } @@ -257,22 +269,13 @@ void ctbin::run(void) // Skip observation if we have a binned observation if (obs->eventtype() == "CountsCube") { if (logTerse()) { - log << "Warning: Skipping binned observation \""; - log << obs->name()+"\"" << std::endl; + log << " Skipping binned "; + log << obs->instrument(); + log << " observation" << std::endl; } continue; } - // Write header for observation - if (logTerse()) { - if (obs->name().length() > 1) { - log.header3("Observation "+obs->name()); - } - else { - log.header3("Observation"); - } - } - // Fill the cube fill_cube(obs); diff --git a/src/ctobssim/ctobssim.cpp b/src/ctobssim/ctobssim.cpp index 0344d20..3baf666 100644 --- a/src/ctobssim/ctobssim.cpp +++ b/src/ctobssim/ctobssim.cpp @@ -326,12 +326,14 @@ void ctobssim::run(void) // Write header for observation if (logTerse()) { + std::string header = m_obs[i]->instrument() + " observation"; if (m_obs[i]->name().length() > 1) { - wrklog.header3("Observation "+m_obs[i]->name()); + header += " \"" + m_obs[i]->name() + "\""; } - else { - wrklog.header3("Observation"); + if (m_obs[i]->id().length() > 1) { + header += " (id=" + m_obs[i]->id() +")"; } + wrklog.header3(header); } // Get pointer on CTA observation @@ -340,10 +342,9 @@ void ctobssim::run(void) // Skip observation if it's not CTA if (obs == NULL) { if (logTerse()) { - wrklog << " Skipping "+m_obs[i]->instrument(); - wrklog << " observation \""; - wrklog << m_obs[i]->name() << "\""; - wrklog << " (id=" << m_obs[i]->id() << ")" << std::endl; + wrklog << " Skipping "; + wrklog << m_obs[i]->instrument(); + wrklog << " observation" << std::endl; } continue; } @@ -353,9 +354,7 @@ void ctobssim::run(void) if (logTerse()) { wrklog << " Skipping binned "; wrklog << obs->instrument(); - wrklog << " observation \""; - wrklog << obs->name()+"\""; - wrklog << " (id=" << obs->id() << ")" << std::endl; + wrklog << " observation" << std::endl; } continue; } -- libgit2 0.21.4