//
// This file is in the Public Domain, and comes with no warranty.
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
#include "logger.hxx"
-#include STL_FSTREAM
+#include <fstream>
#include <string>
-SG_USING_STD(ofstream);
-SG_USING_STD(endl);
-SG_USING_STD(string);
-
#include <simgear/debug/logstream.hxx>
#include "fg_props.hxx"
-
+using std::string;
+using std::endl;
\f
////////////////////////////////////////////////////////////////////////
// Implementation of FGLogger
if (logging == 0)
return;
- vector<SGPropertyNode_ptr> children = logging->getChildren("log");
+ std::vector<SGPropertyNode_ptr> children = logging->getChildren("log");
for (unsigned int i = 0; i < children.size(); i++) {
SGPropertyNode * child = children[i];
}
log.interval_ms = child->getLongValue("interval-ms");
+ log.last_time_ms = globals->get_sim_time_sec() * 1000;
log.delimiter = delimiter.c_str()[0];
- log.output = new ofstream(filename.c_str());
+ log.output = new std::ofstream(filename.c_str());
if (!log.output) {
- SG_LOG(SG_INPUT, SG_ALERT, "Cannot write log to " << filename);
+ SG_LOG(SG_GENERAL, SG_ALERT, "Cannot write log to " << filename);
continue;
}
//
// Process the individual entries (Time is automatic).
//
- vector<SGPropertyNode_ptr> entries = child->getChildren("entry");
+ std::vector<SGPropertyNode_ptr> entries = child->getChildren("entry");
(*log.output) << "Time";
for (unsigned int j = 0; j < entries.size(); j++) {
SGPropertyNode * entry = entries[j];
fgGetNode(entry->getStringValue("property"), true);
log.nodes.push_back(node);
(*log.output) << log.delimiter
- << entry->getStringValue("title", node->getPath());
+ << entry->getStringValue("title", node->getPath().c_str());
}
(*log.output) << endl;
}
void
FGLogger::update (double dt)
{
- double sim_time_ms = globals->get_sim_time_sec() * 1000;
- for (unsigned int i = 0; i < _logs.size(); i++) {
- if ((sim_time_ms - _logs[i].last_time_ms) >= _logs[i].interval_ms) {
- _logs[i].last_time_ms = sim_time_ms;
- (*_logs[i].output) << sim_time_ms;
- for (unsigned int j = 0; j < _logs[i].nodes.size(); j++) {
- (*_logs[i].output) << _logs[i].delimiter
+ double sim_time_sec = globals->get_sim_time_sec();
+ double sim_time_ms = sim_time_sec * 1000;
+ for (unsigned int i = 0; i < _logs.size(); i++) {
+ while ((sim_time_ms - _logs[i].last_time_ms) >= _logs[i].interval_ms) {
+ _logs[i].last_time_ms += _logs[i].interval_ms;
+ (*_logs[i].output) << sim_time_sec;
+ for (unsigned int j = 0; j < _logs[i].nodes.size(); j++) {
+ (*_logs[i].output) << _logs[i].delimiter
<< _logs[i].nodes[j]->getStringValue();
- }
- (*_logs[i].output) << endl;
+ }
+ (*_logs[i].output) << endl;
+ }
}
- }
}