diff --git a/src/models/FGExternalReactions.cpp b/src/models/FGExternalReactions.cpp index 4e28c31c58..94326d346f 100644 --- a/src/models/FGExternalReactions.cpp +++ b/src/models/FGExternalReactions.cpp @@ -36,9 +36,11 @@ HISTORY INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ +#include "FGFDMExec.h" #include "FGExternalForce.h" #include "FGExternalReactions.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" using namespace std; @@ -173,12 +175,14 @@ void FGExternalReactions::Debug(int from) if (from == 0) { // Constructor - loading and initialization } if (from == 2) { // Loading - cout << endl << " External Reactions: " << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + log << "\n External Reactions: \n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGExternalReactions" << endl; - if (from == 1) cout << "Destroyed: FGExternalReactions" << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGExternalReactions\n"; + if (from == 1) log << "Destroyed: FGExternalReactions\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/FGGasCell.cpp b/src/models/FGGasCell.cpp index 8fcc635732..45281b8b85 100644 --- a/src/models/FGGasCell.cpp +++ b/src/models/FGGasCell.cpp @@ -39,10 +39,8 @@ INCLUDES #include "models/FGMassBalance.h" #include "FGGasCell.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" -using std::cerr; -using std::endl; -using std::cout; using std::string; using std::max; @@ -86,9 +84,9 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num, if (element) { vXYZ = element->FindElementTripletConvertTo("IN"); } else { - const string s("Fatal Error: No location found for this gas cell."); - cerr << el->ReadFrom() << endl << s << endl; - throw BaseException(s); + FGXMLLogging log(exec->GetLogger(), el, LogLevel::FATAL); + log << "\nFatal Error: No location found for this gas cell.\n"; + throw BaseException(log.str()); } if ((el->FindElement("x_radius") || el->FindElement("x_width")) && (el->FindElement("y_radius") || el->FindElement("y_width")) && @@ -126,7 +124,8 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num, // Cylindrical volume. MaxVolume = M_PI * Yradius * Zradius * Xwidth; } else { - cerr << "Warning: Unsupported gas cell shape." << endl; + FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN); + log << "Unsupported gas cell shape.\n"; MaxVolume = (4.0 * M_PI * Xradius * Yradius * Zradius / 3.0 + M_PI * Yradius * Zradius * Xwidth + @@ -138,9 +137,9 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num, Xwidth * Ywidth * Zwidth); } } else { - const string s("Fatal Error: Gas cell shape must be given."); - cerr << el->ReadFrom() << endl << s << endl; - throw BaseException(s); + FGXMLLogging log(exec->GetLogger(), el, LogLevel::FATAL); + log << "\nGas cell shape must be given.\n"; + throw BaseException(log.str()); } if (el->FindElement("max_overpressure")) { MaxOverpressure = el->FindElementValueAsNumberConvertTo("max_overpressure", @@ -151,7 +150,8 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num, if (0 <= Fullness) { Volume = Fullness * MaxVolume; } else { - cerr << "Warning: Invalid initial gas cell fullness value." << endl; + FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN); + log << "Invalid initial gas cell fullness value.\n"; } } if (el->FindElement("valve_coefficient")) { @@ -448,38 +448,38 @@ void FGGasCell::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " Gas cell holds " << Contents << " mol " << - type << endl; - cout << " Cell location (X, Y, Z) (in.): " << vXYZ(eX) << ", " << - vXYZ(eY) << ", " << vXYZ(eZ) << endl; - cout << " Maximum volume: " << MaxVolume << " ft3" << endl; - cout << " Relief valve release pressure: " << MaxOverpressure << - " lbs/ft2" << endl; - cout << " Manual valve coefficient: " << ValveCoefficient << - " ft4*sec/slug" << endl; - cout << " Initial temperature: " << Temperature << " Rankine" << - endl; - cout << " Initial pressure: " << Pressure << " lbs/ft2" << endl; - cout << " Initial volume: " << Volume << " ft3" << endl; - cout << " Initial mass: " << GetMass() << " slug mass" << endl; - cout << " Initial weight: " << GetMass()*slugtolb << " lbs force" << - endl; - cout << " Heat transfer: " << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + log << " Gas cell holds " << fixed << Contents << " mol " << type << "\n"; + log << " Cell location (X, Y, Z) (in.): " << vXYZ(eX) << ", " + << vXYZ(eY) << ", " << vXYZ(eZ) << "\n"; + log << " Maximum volume: " << MaxVolume << " ft3\n"; + log << " Relief valve release pressure: " << MaxOverpressure + << " lbs/ft2\n"; + log << " Manual valve coefficient: " << ValveCoefficient + << " ft4*sec/slug\n"; + log << " Initial temperature: " << Temperature << " Rankine\n"; + log << " Initial pressure: " << Pressure << " lbs/ft2\n"; + log << " Initial volume: " << Volume << " ft3\n"; + log << " Initial mass: " << GetMass() << " slug mass\n"; + log << " Initial weight: " << GetMass()*slugtolb << " lbs force\n"; + log << " Heat transfer: \n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGGasCell" << endl; - if (from == 1) cout << "Destroyed: FGGasCell" << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGGasCell\n"; + if (from == 1) log << "Destroyed: FGGasCell\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } if (debug_lvl & 8 ) { // Runtime state variables - cout << " " << type << " cell holds " << Contents << " mol " << endl; - cout << " Temperature: " << Temperature << " Rankine" << endl; - cout << " Pressure: " << Pressure << " lbs/ft2" << endl; - cout << " Volume: " << Volume << " ft3" << endl; - cout << " Mass: " << GetMass() << " slug mass" << endl; - cout << " Weight: " << GetMass()*slugtolb << " lbs force" << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + log << " " << type << " cell holds " << fixed << Contents << " mol\n"; + log << " Temperature: " << Temperature << " Rankine\n"; + log << " Pressure: " << Pressure << " lbs/ft2\n"; + log << " Volume: " << Volume << " ft3\n"; + log << " Mass: " << GetMass() << " slug mass\n"; + log << " Weight: " << GetMass()*slugtolb << " lbs force\n"; } if (debug_lvl & 16) { // Sanity checking } @@ -519,9 +519,9 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, if (element) { vXYZ = element->FindElementTripletConvertTo("IN"); } else { - const string s("Fatal Error: No location found for this ballonet."); - cerr << el->ReadFrom() << endl << s << endl; - throw BaseException(s); + FGXMLLogging log(exec->GetLogger(), el, LogLevel::FATAL); + log << "\nFatal Error: No location found for this ballonet.\n"; + throw BaseException(log.str()); } if ((el->FindElement("x_radius") || el->FindElement("x_width")) && (el->FindElement("y_radius") || el->FindElement("y_width")) && @@ -559,7 +559,8 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, // Cylindrical volume. MaxVolume = M_PI * Yradius * Zradius * Xwidth; } else { - cerr << "Warning: Unsupported ballonet shape." << endl; + FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN); + log << "Unsupported ballonet shape.\n"; MaxVolume = (4.0 * M_PI * Xradius * Yradius * Zradius / 3.0 + M_PI * Yradius * Zradius * Xwidth + @@ -571,9 +572,9 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, Xwidth * Ywidth * Zwidth); } } else { - const string s("Fatal Error: Ballonet shape must be given."); - cerr << el->ReadFrom() << endl << s << endl; - throw BaseException(s); + FGXMLLogging log(exec->GetLogger(), el, LogLevel::FATAL); + log << "\nFatal Error: Ballonet shape must be given.\n"; + throw BaseException(log.str()); } if (el->FindElement("max_overpressure")) { MaxOverpressure = el->FindElementValueAsNumberConvertTo("max_overpressure", @@ -584,7 +585,8 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, if (0 <= Fullness) { Volume = Fullness * MaxVolume; } else { - cerr << "Warning: Invalid initial ballonet fullness value." << endl; + FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN); + log << "Invalid initial ballonet fullness value.\n"; } } if (el->FindElement("valve_coefficient")) { @@ -798,38 +800,39 @@ void FGBallonet::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " Ballonet holds " << Contents << " mol air" << endl; - cout << " Location (X, Y, Z) (in.): " << vXYZ(eX) << ", " << - vXYZ(eY) << ", " << vXYZ(eZ) << endl; - cout << " Maximum volume: " << MaxVolume << " ft3" << endl; - cout << " Relief valve release pressure: " << MaxOverpressure << - " lbs/ft2" << endl; - cout << " Relief valve coefficient: " << ValveCoefficient << - " ft4*sec/slug" << endl; - cout << " Initial temperature: " << Temperature << " Rankine" << - endl; - cout << " Initial pressure: " << Pressure << " lbs/ft2" << endl; - cout << " Initial volume: " << Volume << " ft3" << endl; - cout << " Initial mass: " << GetMass() << " slug mass" << endl; - cout << " Initial weight: " << GetMass()*slugtolb << - " lbs force" << endl; - cout << " Heat transfer: " << endl; + FGLogging log(MassBalance->GetExec()->GetLogger(), LogLevel::DEBUG); + log << " Ballonet holds " << fixed << Contents << " mol air\n"; + log << " Location (X, Y, Z) (in.): " << vXYZ(eX) << ", " + << vXYZ(eY) << ", " << vXYZ(eZ) << "\n"; + log << " Maximum volume: " << MaxVolume << " ft3\n"; + log << " Relief valve release pressure: " << MaxOverpressure + << " lbs/ft2\n"; + log << " Relief valve coefficient: " << ValveCoefficient + << " ft4*sec/slug\n"; + log << " Initial temperature: " << Temperature << " Rankine\n"; + log << " Initial pressure: " << Pressure << " lbs/ft2\n"; + log << " Initial volume: " << Volume << " ft3\n"; + log << " Initial mass: " << GetMass() << " slug mass\n"; + log << " Initial weight: " << GetMass()*slugtolb + << " lbs force\n"; + log << " Heat transfer: \n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGBallonet" << endl; - if (from == 1) cout << "Destroyed: FGBallonet" << endl; + FGLogging log(MassBalance->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGBallonet\n"; + if (from == 1) log << "Destroyed: FGBallonet\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } if (debug_lvl & 8 ) { // Runtime state variables - cout << " Ballonet holds " << Contents << - " mol air" << endl; - cout << " Temperature: " << Temperature << " Rankine" << endl; - cout << " Pressure: " << Pressure << " lbs/ft2" << endl; - cout << " Volume: " << Volume << " ft3" << endl; - cout << " Mass: " << GetMass() << " slug mass" << endl; - cout << " Weight: " << GetMass()*slugtolb << " lbs force" << endl; + FGLogging log(MassBalance->GetExec()->GetLogger(), LogLevel::DEBUG); + log << " Ballonet holds " << fixed << Contents << " mol air\n"; + log << " Temperature: " << Temperature << " Rankine\n"; + log << " Pressure: " << Pressure << " lbs/ft2\n"; + log << " Volume: " << Volume << " ft3\n"; + log << " Mass: " << GetMass() << " slug mass\n"; + log << " Weight: " << GetMass()*slugtolb << " lbs force\n"; } if (debug_lvl & 16) { // Sanity checking } diff --git a/src/models/FGGroundReactions.cpp b/src/models/FGGroundReactions.cpp index 2fed6f51a7..c707440cdc 100644 --- a/src/models/FGGroundReactions.cpp +++ b/src/models/FGGroundReactions.cpp @@ -41,6 +41,7 @@ INCLUDES #include "FGGroundReactions.h" #include "FGAccelerations.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" using namespace std; @@ -272,12 +273,14 @@ void FGGroundReactions::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 2) { // Loading - cout << endl << " Ground Reactions: " << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + log << "\n Ground Reactions: \n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGGroundReactions" << endl; - if (from == 1) cout << "Destroyed: FGGroundReactions" << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGGroundReactions\n"; + if (from == 1) log << "Destroyed: FGGroundReactions\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/FGLGear.cpp b/src/models/FGLGear.cpp index d9aae6a6d3..b6346447ee 100644 --- a/src/models/FGLGear.cpp +++ b/src/models/FGLGear.cpp @@ -44,9 +44,10 @@ INCLUDES #include "FGLGear.h" #include "FGFDMExec.h" #include "models/FGGroundReactions.h" +#include "models/FGInertial.h" #include "math/FGTable.h" #include "input_output/FGXMLElement.h" -#include "models/FGInertial.h" +#include "input_output/FGLog.h" using namespace std; @@ -173,7 +174,8 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number, const struct Inputs& ForceY_Table = new FGTable(PropertyManager, force_table); break; } else { - cerr << "Undefined force table for " << name << " contact point" << endl; + FGXMLLogging log(fdmex->GetLogger(), force_table, LogLevel::ERROR); + log << "Undefined force table for " << name << " contact point\n"; } force_table = el->FindNextElement("table"); } @@ -181,10 +183,9 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number, const struct Inputs& Element* element = el->FindElement("location"); if (element) vXYZn = element->FindElementTripletConvertTo("IN"); else { - stringstream s; - s << "No location given for contact " << name; - cerr << endl << s.str() << endl; - throw BaseException(s.str()); + FGXMLLogging log(fdmex->GetLogger(), el, LogLevel::FATAL); + log << "\nNo location given for contact " << name << "\n"; + throw BaseException(log.str()); } SetTransformType(FGForce::tCustom); @@ -210,8 +211,9 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number, const struct Inputs& else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone; else if (sBrakeGroup.empty() ) eBrakeGrp = bgNone; else { - cerr << "Improper braking group specification in config file: " - << sBrakeGroup << " is undefined." << endl; + FGXMLLogging log(fdmex->GetLogger(), el, LogLevel::ERROR); + log << "Improper braking group specification in config file: " + << sBrakeGroup << " is undefined.\n"; } // Add some AI here to determine if gear is located properly according to its @@ -297,7 +299,7 @@ const FGColumnVector3& FGLGear::GetBodyForces(void) double height = fdmex->GetInertial()->GetContactPoint(gearLoc, contact, normal, terrainVel, dummy); - // Don't want strut compression when in contact with the ground to return + // Don't want strut compression when in contact with the ground to return // a negative AGL AGL = max(height, 0.0); @@ -548,8 +550,9 @@ void FGLGear::ReportTakeoffOrLanding(void) if (lastWOW != WOW) { if (debug_lvl > 0) { - cout << "GEAR_CONTACT: " << fdmex->GetSimTime() << " seconds: " << name - << " " << WOW << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + log << "GEAR_CONTACT: " << fixed << fdmex->GetSimTime() << " seconds: " + << name << " " << WOW << "\n"; } } } @@ -565,7 +568,9 @@ void FGLGear::CrashDetect(void) SinkRate > 1.4666*30 ) && !fdmex->IntegrationSuspended()) { if (debug_lvl > 0) { - cout << "*CRASH DETECTED* " << fdmex->GetSimTime() << " seconds: " << name; + FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + log << "*CRASH DETECTED* " << fixed << fdmex->GetSimTime() << " seconds: " + << name << "\n"; } // fdmex->SuspendIntegration(); @@ -863,34 +868,36 @@ void FGLGear::Report(ReportType repType) { if (fabs(TakeoffDistanceTraveled) < 0.001) return; // Don't print superfluous reports + FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + switch(repType) { case erLand: - cout << endl << "Touchdown report for " << name << " (WOW at time: " - << fdmex->GetSimTime() << " seconds)" << endl; - cout << " Sink rate at contact: " << SinkRate << " fps, " - << SinkRate*0.3048 << " mps" << endl; - cout << " Contact ground speed: " << GroundSpeed*.5925 << " knots, " - << GroundSpeed*0.3048 << " mps" << endl; - cout << " Maximum contact force: " << MaximumStrutForce << " lbs, " - << MaximumStrutForce*4.448 << " Newtons" << endl; - cout << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, " - << MaximumStrutTravel*30.48 << " cm" << endl; - cout << " Distance traveled: " << LandingDistanceTraveled << " ft, " - << LandingDistanceTraveled*0.3048 << " meters" << endl; + log << "\nTouchdown report for " << name << " (WOW at time: " << fixed + << fdmex->GetSimTime() << " seconds)\n"; + log << " Sink rate at contact: " << SinkRate << " fps, " + << SinkRate*0.3048 << " mps\n"; + log << " Contact ground speed: " << GroundSpeed*.5925 << " knots, " + << GroundSpeed*0.3048 << " mps\n"; + log << " Maximum contact force: " << MaximumStrutForce << " lbs, " + << MaximumStrutForce*4.448 << " Newtons\n"; + log << " Maximum strut travel: " << MaximumStrutTravel*12.0 << " inches, " + << MaximumStrutTravel*30.48 << " cm\n"; + log << " Distance traveled: " << LandingDistanceTraveled << " ft, " + << LandingDistanceTraveled*0.3048 << " meters\n"; LandingReported = true; break; case erTakeoff: - cout << endl << "Takeoff report for " << name << " (Liftoff at time: " - << fdmex->GetSimTime() << " seconds)" << endl; - cout << " Distance traveled: " << TakeoffDistanceTraveled - << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters" << endl; - cout << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft - << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters" << endl; - cout << " [Altitude (ASL): " << in.DistanceASL << " ft. / " + log << "\nTakeoff report for " << name << " (Liftoff at time: " << fixed + << fdmex->GetSimTime() << " seconds)\n"; + log << " Distance traveled: " << TakeoffDistanceTraveled + << " ft, " << TakeoffDistanceTraveled*0.3048 << " meters\n"; + log << " Distance traveled (over 50'): " << TakeoffDistanceTraveled50ft + << " ft, " << TakeoffDistanceTraveled50ft*0.3048 << " meters\n"; + log << " [Altitude (ASL): " << in.DistanceASL << " ft. / " << in.DistanceASL*FGJSBBase::fttom << " m | Temperature: " << in.Temperature - 459.67 << " F / " - << RankineToCelsius(in.Temperature) << " C]" << endl; - cout << " [Velocity (KCAS): " << in.VcalibratedKts << "]" << endl; + << RankineToCelsius(in.Temperature) << " C]\n"; + log << " [Velocity (KCAS): " << in.VcalibratedKts << "]\n"; TakeoffReported = true; break; case erNone: @@ -926,35 +933,37 @@ void FGLGear::Debug(int from) if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); if (from == 0) { // Constructor - loading and initialization - cout << " " << sContactType[eContactType] << " " << name << endl; - cout << " Location: " << vXYZn << endl; - cout << " Spring Constant: " << kSpring << endl; + log << " " << sContactType[eContactType] << " " << name << "\n" << fixed; + log << " Location: " << vXYZn << "\n"; + log << " Spring Constant: " << kSpring << "\n"; if (eDampType == dtLinear) - cout << " Damping Constant: " << bDamp << " (linear)" << endl; + log << " Damping Constant: " << bDamp << " (linear)\n"; else - cout << " Damping Constant: " << bDamp << " (square law)" << endl; + log << " Damping Constant: " << bDamp << " (square law)\n"; if (eDampTypeRebound == dtLinear) - cout << " Rebound Damping Constant: " << bDampRebound << " (linear)" << endl; + log << " Rebound Damping Constant: " << bDampRebound << " (linear)\n"; else - cout << " Rebound Damping Constant: " << bDampRebound << " (square law)" << endl; + log << " Rebound Damping Constant: " << bDampRebound << " (square law)\n"; - cout << " Dynamic Friction: " << dynamicFCoeff << endl; - cout << " Static Friction: " << staticFCoeff << endl; + log << " Dynamic Friction: " << dynamicFCoeff << "\n"; + log << " Static Friction: " << staticFCoeff << "\n"; if (eContactType == ctBOGEY) { - cout << " Rolling Friction: " << rollingFCoeff << endl; - cout << " Steering Type: " << sSteerType[eSteerType] << endl; - cout << " Grouping: " << sBrakeGroup[eBrakeGrp] << endl; - cout << " Max Steer Angle: " << maxSteerAngle << endl; - cout << " Retractable: " << isRetractable << endl; + log << " Rolling Friction: " << rollingFCoeff << "\n"; + log << " Steering Type: " << sSteerType[eSteerType] << "\n"; + log << " Grouping: " << sBrakeGroup[eBrakeGrp] << "\n"; + log << " Max Steer Angle: " << maxSteerAngle << "\n"; + log << " Retractable: " << isRetractable << "\n"; } } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGLGear" << endl; - if (from == 1) cout << "Destroyed: FGLGear" << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGLGear\n"; + if (from == 1) log << "Destroyed: FGLGear\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/FGOutput.cpp b/src/models/FGOutput.cpp index c310aa5be5..c57e01e17c 100644 --- a/src/models/FGOutput.cpp +++ b/src/models/FGOutput.cpp @@ -44,6 +44,7 @@ INCLUDES #include "input_output/FGOutputFG.h" #include "input_output/FGXMLFileRead.h" #include "input_output/FGModelLoader.h" +#include "input_output/FGLog.h" using namespace std; @@ -180,8 +181,10 @@ bool FGOutput::SetDirectivesFile(const SGPath& fname) } bool result = Load(document); - if (!result) - cerr << endl << "Aircraft output element has problems in file " << fname << endl; + if (!result) { + FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + log << "\nAircraft output element has problems in file " << fname << "\n"; + } return result; } @@ -195,7 +198,10 @@ bool FGOutput::Load(int subSystems, std::string protocol, std::string type, size_t idx = OutputTypes.size(); FGOutputType* Output = 0; - if (debug_lvl > 0) cout << endl << " Output data set: " << idx << endl; + if (debug_lvl > 0) { + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + log << "\n Output data set: " << idx << "\n"; + } type = to_upper(type); @@ -216,7 +222,8 @@ bool FGOutput::Load(int subSystems, std::string protocol, std::string type, } else if (type == "TERMINAL") { // Not done yet } else if (type != string("NONE")) { - cerr << "Unknown type of output specified in config file" << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + log << "Unknown type of output specified in config file\n"; } if (!Output) return false; @@ -248,7 +255,10 @@ bool FGOutput::Load(Element* document, const SGPath& dir) string type = document->GetAttributeValue("type"); FGOutputType* Output = 0; - if (debug_lvl > 0) cout << endl << " Output data set: " << idx << " " << endl; + if (debug_lvl > 0) { + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + log << "\n Output data set: " << idx << " \n"; + } type = to_upper(type); @@ -263,7 +273,8 @@ bool FGOutput::Load(Element* document, const SGPath& dir) } else if (type == "TERMINAL") { // Not done yet } else if (type != string("NONE")) { - cerr << "Unknown type of output specified in config file" << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + log << "Unknown type of output specified in config file\n"; } if (!Output) return false; @@ -323,8 +334,9 @@ void FGOutput::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGOutput" << endl; - if (from == 1) cout << "Destroyed: FGOutput" << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGOutput\n"; + if (from == 1) log << "Destroyed: FGOutput\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/FGPropulsion.cpp b/src/models/FGPropulsion.cpp index 36faf78589..8280cd5593 100644 --- a/src/models/FGPropulsion.cpp +++ b/src/models/FGPropulsion.cpp @@ -49,6 +49,8 @@ INCLUDES #include "FGFDMExec.h" #include "FGPropulsion.h" +#include "input_output/FGModelLoader.h" +#include "input_output/FGLog.h" #include "models/FGMassBalance.h" #include "models/propulsion/FGRocket.h" #include "models/propulsion/FGTurbine.h" @@ -56,7 +58,6 @@ INCLUDES #include "models/propulsion/FGElectric.h" #include "models/propulsion/FGTurboProp.h" #include "models/propulsion/FGTank.h" -#include "input_output/FGModelLoader.h" #include "models/propulsion/FGBrushLessDCMotor.h" @@ -365,7 +366,8 @@ bool FGPropulsion::Load(Element* el) if (tank->GetType() == FGTank::ttFUEL) FuelDensity = tank->GetDensity(); else if (tank->GetType() != FGTank::ttOXIDIZER) { - cerr << "Unknown tank type specified." << endl; + FGXMLLogging log(FDMExec->GetLogger(), tank_element, LogLevel::ERROR); + log << "Unknown tank type specified.\n"; return false; } numTanks++; @@ -405,11 +407,13 @@ bool FGPropulsion::Load(Element* el) Engines.push_back(make_shared(FDMExec, element, numEngines, in)); } else { - cerr << engine_element->ReadFrom() << " Unknown engine type" << endl; + FGXMLLogging log(FDMExec->GetLogger(), engine_element, LogLevel::ERROR); + log << " Unknown engine type\n"; return false; } } catch (std::string& str) { - cerr << endl << fgred << str << reset << endl; + FGXMLLogging log(FDMExec->GetLogger(), engine_element, LogLevel::ERROR); + log << "\n" << LogFormat::RED << str << LogFormat::RESET << "\n"; return false; } @@ -541,7 +545,7 @@ string FGPropulsion::GetPropulsionTankReport() << right << setw(12) << tank->GetContents() << setw(8) << tank->GetXYZ(eX) << setw(8) << tank->GetXYZ(eY) << setw(8) << tank->GetXYZ(eZ) << setw(12) << tank->GetIxx() << setw(12) << tank->GetIyy() - << setw(12) << tank->GetIzz() << endl; + << setw(12) << tank->GetIzz() << "\n"; } return outstream.str(); } @@ -854,12 +858,14 @@ void FGPropulsion::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 2) { // Loader - cout << endl << " Propulsion:" << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + log << "\n Propulsion:\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGPropulsion" << endl; - if (from == 1) cout << "Destroyed: FGPropulsion" << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGPropulsion\n"; + if (from == 1) log << "Destroyed: FGPropulsion\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/atmosphere/FGMSIS.cpp b/src/models/atmosphere/FGMSIS.cpp index dab5dd60c5..5558c1a06d 100644 --- a/src/models/atmosphere/FGMSIS.cpp +++ b/src/models/atmosphere/FGMSIS.cpp @@ -60,6 +60,7 @@ INCLUDES #include "FGFDMExec.h" #include "FGMSIS.h" +#include "input_output/FGLog.h" using namespace std; @@ -212,7 +213,7 @@ void FGMSIS::Compute(double altitude, double& pressure, double& temperature, // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -230,14 +231,16 @@ void FGMSIS::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) {} // Constructor if (from == 3) { // Loading - cout << " NRLMSIS atmosphere model" << endl; - cout << " day: " << day_of_year << endl; - cout << " UTC: " << seconds_in_day << endl << endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + log << " NRLMSIS atmosphere model\n" << fixed; + log << " day: " << day_of_year << "\n"; + log << " UTC: " << seconds_in_day << "\n\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) std::cout << "Instantiated: MSIS" << std::endl; - if (from == 1) std::cout << "Destroyed: MSIS" << std::endl; + FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: MSIS\n"; + if (from == 1) log << "Destroyed: MSIS\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGAccelerometer.cpp b/src/models/flight_control/FGAccelerometer.cpp index 6d7962815e..95b4122b0b 100644 --- a/src/models/flight_control/FGAccelerometer.cpp +++ b/src/models/flight_control/FGAccelerometer.cpp @@ -52,19 +52,19 @@ CLASS IMPLEMENTATION FGAccelerometer::FGAccelerometer(FGFCS* fcs, Element* element) : FGSensor(fcs, element), - FGSensorOrientation(element) + FGSensorOrientation(element, fcs->GetExec()->GetLogger()) { Propagate = fcs->GetExec()->GetPropagate(); Accelerations = fcs->GetExec()->GetAccelerations(); MassBalance = fcs->GetExec()->GetMassBalance(); - + Element* location_element = element->FindElement("location"); if (location_element) vLocation = location_element->FindElementTripletConvertTo("IN"); else { - cerr << element->ReadFrom() - << "No location given for accelerometer. " << endl; - throw("Malformed accelerometer specification"); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "No location given for accelerometer.\n"; + throw BaseException(log.str()); } vRadius = MassBalance->StructuralToBody(vLocation); @@ -86,7 +86,7 @@ bool FGAccelerometer::Run(void ) // There is no input assumed. This is a dedicated acceleration sensor. vRadius = MassBalance->StructuralToBody(vLocation); - + //aircraft forces vAccel = (Accelerations->GetBodyAccel() + Accelerations->GetPQRidot() * vRadius @@ -112,7 +112,7 @@ bool FGAccelerometer::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -131,12 +131,14 @@ void FGAccelerometer::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " Axis: " << ax[axis] << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + log << " Axis: " << ax[axis] << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGAccelerometer" << endl; - if (from == 1) cout << "Destroyed: FGAccelerometer" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGAccelerometer\n"; + if (from == 1) log << "Destroyed: FGAccelerometer\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGActuator.cpp b/src/models/flight_control/FGActuator.cpp index e2d40666e8..44b213e5ea 100644 --- a/src/models/flight_control/FGActuator.cpp +++ b/src/models/flight_control/FGActuator.cpp @@ -41,6 +41,7 @@ INCLUDES #include "input_output/FGXMLElement.h" #include "math/FGParameterValue.h" #include "models/FGFCS.h" +#include "input_output/FGLog.h" using namespace std; @@ -319,7 +320,7 @@ void FGActuator::InitializeLagCoefficients() // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -336,27 +337,30 @@ void FGActuator::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " INPUT: " << InputNodes[0]->GetNameWithSign() << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + log << " INPUT: " << InputNodes[0]->GetNameWithSign() << fixed + << setprecision(4) << "\n"; if (!OutputNodes.empty()) { for (auto node: OutputNodes) - cout << " OUTPUT: " << node->GetName() << endl; + log << " OUTPUT: " << node->GetName() << "\n"; } - if (bias != 0.0) cout << " Bias: " << bias << endl; + if (bias != 0.0) log << " Bias: " << bias << "\n"; if (rate_limit_incr != 0) { - cout << " Increasing rate limit: " << rate_limit_incr->GetName() << endl; + log << " Increasing rate limit: " << rate_limit_incr->GetName() << "\n"; } if (rate_limit_decr != 0) { - cout << " Decreasing rate limit: " << rate_limit_decr->GetName() << endl; + log << " Decreasing rate limit: " << rate_limit_decr->GetName() << "\n"; } - if (lag != 0) cout << " Actuator lag: " << lag->GetName() << endl; - if (hysteresis_width != 0) cout << " Hysteresis width: " << hysteresis_width << endl; - if (deadband_width != 0) cout << " Deadband width: " << deadband_width << endl; + if (lag != 0) log << " Actuator lag: " << lag->GetName() << "\n"; + if (hysteresis_width != 0) log << " Hysteresis width: " << hysteresis_width << "\n"; + if (deadband_width != 0) log << " Deadband width: " << deadband_width << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGActuator" << endl; - if (from == 1) cout << "Destroyed: FGActuator" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGActuator\n"; + if (from == 1) log << "Destroyed: FGActuator\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGAngles.cpp b/src/models/flight_control/FGAngles.cpp index 0b53ccef8b..40818e477a 100644 --- a/src/models/flight_control/FGAngles.cpp +++ b/src/models/flight_control/FGAngles.cpp @@ -39,7 +39,7 @@ COMMENTS, REFERENCES, and NOTES from the current heading. The sense of the rotation to get to that angle is also calculated (positive 1 for a clockwise rotation, negative 1 for counter- clockwise). - + The angle to the heading is calculated as follows: Given an angle phi: @@ -70,6 +70,7 @@ INCLUDES #include "FGAngles.h" #include "models/FGFCS.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" using namespace std; @@ -167,7 +168,7 @@ bool FGAngles::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -187,8 +188,9 @@ void FGAngles::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGAngles" << endl; - if (from == 1) cout << "Destroyed: FGAngles" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGAngles\n"; + if (from == 1) log << "Destroyed: FGAngles\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGDeadBand.cpp b/src/models/flight_control/FGDeadBand.cpp index a9c7dc6b2b..6b6eeec8e1 100644 --- a/src/models/flight_control/FGDeadBand.cpp +++ b/src/models/flight_control/FGDeadBand.cpp @@ -40,6 +40,7 @@ INCLUDES #include "FGDeadBand.h" #include "models/FGFCS.h" #include "math/FGParameterValue.h" +#include "input_output/FGLog.h" using namespace std; @@ -110,7 +111,7 @@ bool FGDeadBand::Run(void) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -127,17 +128,19 @@ void FGDeadBand::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " INPUT: " << InputNodes[0]->GetName() << endl; - cout << " DEADBAND WIDTH: " << Width->GetName() << endl; - cout << " GAIN: " << gain << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + log << " INPUT: " << InputNodes[0]->GetName() << "\n"; + log << " DEADBAND WIDTH: " << Width->GetName() << "\n"; + log << " GAIN: " << fixed << setprecision(4) << gain << "\n"; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getNameString() << endl; + log << " OUTPUT: " << node->getNameString() << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGDeadBand" << endl; - if (from == 1) cout << "Destroyed: FGDeadBand" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGDeadBand\n"; + if (from == 1) log << "Destroyed: FGDeadBand\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGDistributor.cpp b/src/models/flight_control/FGDistributor.cpp index 38a3014491..288d166106 100644 --- a/src/models/flight_control/FGDistributor.cpp +++ b/src/models/flight_control/FGDistributor.cpp @@ -38,9 +38,10 @@ Also, see the header file (FGDistributor.h) for further details. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% INCLUDES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ - + #include "FGDistributor.h" #include "models/FGFCS.h" +#include "input_output/FGLog.h" using namespace std; @@ -120,7 +121,7 @@ bool FGDistributor::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -137,29 +138,31 @@ void FGDistributor::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); unsigned int ctr=0; for (auto Case: Cases) { - std::cout << " Case: " << ctr << endl; + log << " Case: " << fixed << ctr << "\n"; if (Case->HasTest()) { Case->GetTest()->PrintCondition(" "); } else { - std::cout << " Set these properties by default: " << std::endl; + log << " Set these properties by default: \n"; } - std::cout << std::endl; + log << "\n"; for (auto propVal = Case->IterPropValPairs(); propVal != Case->EndPropValPairs(); ++propVal) { - std::cout << " Set property " << (*propVal)->GetPropName(); - if ((*propVal)->GetLateBoundProp()) std::cout << " (late bound)"; - std::cout << " to " << (*propVal)->GetValString(); - if ((*propVal)->GetLateBoundValue()) std::cout << " (late bound)"; - std::cout << std::endl; + log << " Set property " << (*propVal)->GetPropName(); + if ((*propVal)->GetLateBoundProp()) log << " (late bound)"; + log << " to " << (*propVal)->GetValString(); + if ((*propVal)->GetLateBoundValue()) log << " (late bound)"; + log << "\n"; } ctr++; } } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGDistributor" << endl; - if (from == 1) cout << "Destroyed: FGDistributor" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGDistributor\n"; + if (from == 1) log << "Destroyed: FGDistributor\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGFCSComponent.cpp b/src/models/flight_control/FGFCSComponent.cpp index 6542f2c0d8..1f2e6deb3c 100644 --- a/src/models/flight_control/FGFCSComponent.cpp +++ b/src/models/flight_control/FGFCSComponent.cpp @@ -40,6 +40,7 @@ INCLUDES #include "FGFCSComponent.h" #include "models/FGFCS.h" #include "math/FGParameterValue.h" +#include "input_output/FGLog.h" using namespace std; @@ -131,9 +132,9 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) bool node_exists = PropertyManager->HasNode(output_node_name); FGPropertyNode* OutputNode = PropertyManager->GetNode( output_node_name, true ); if (!OutputNode) { - cerr << out_elem->ReadFrom() << " Unable to process property: " - << output_node_name << endl; - throw(string("Invalid output property name in flight control definition")); + FGXMLLogging log(fcs->GetExec()->GetLogger(), out_elem, LogLevel::FATAL); + log << " Unable to process property: " << output_node_name << "\n"; + throw BaseException(log.str()); } OutputNodes.push_back(OutputNode); // If the node has just been created then it must be initialized to a @@ -157,7 +158,8 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) } else if (delayType == "frames") { delay = (unsigned int)delay_time; } else { - cerr << "Unallowed delay type" << endl; + FGXMLLogging log(fcs->GetExec()->GetLogger(), delay_elem, LogLevel::ERROR); + log << "Unallowed delay type\n"; } } else { delay = (unsigned int)(delay_time / dt); @@ -170,8 +172,8 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) if (clip_el) { Element* el = clip_el->FindElement("min"); if (!el) { - cerr << clip_el->ReadFrom() - << "Element is missing, is ignored." << endl; + FGXMLLogging log(fcs->GetExec()->GetLogger(), clip_el, LogLevel::ERROR); + log << "Element is missing, is ignored.\n"; return; } @@ -179,8 +181,8 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) el = clip_el->FindElement("max"); if (!el) { - cerr << clip_el->ReadFrom() - << "Element is missing, is ignored." << endl; + FGXMLLogging log(fcs->GetExec()->GetLogger(), clip_el, LogLevel::ERROR); + log << "Element is missing, is ignored.\n"; ClipMin = nullptr; return; } @@ -219,20 +221,19 @@ void FGFCSComponent::CheckInputNodes(size_t MinNodes, size_t MaxNodes, Element* size_t num = InputNodes.size(); if (num < MinNodes) { - cerr << el->ReadFrom() - << " Not enough nodes are provided" << endl - << " Expecting " << MinNodes << " while " << num - << " are provided." << endl; - throw("Some inputs are missing."); + FGXMLLogging log(fcs->GetExec()->GetLogger(), el, LogLevel::FATAL); + log << " Not enough nodes are provided\n" + << " Expecting " << MinNodes << " while " << num + << " are provided.\n"; + throw BaseException(log.str()); } if (num > MaxNodes) { - cerr << el->ReadFrom() - << " Too many nodes are provided" << endl - << " Expecting " << MaxNodes << " while " << num - << " are provided." << endl - << " The last " << num-MaxNodes << " input nodes will be ignored." - << endl; + FGXMLLogging log(fcs->GetExec()->GetLogger(), el, LogLevel::ERROR); + log << " Too many nodes are provided\n" + << " Expecting " << MaxNodes << " while " << num + << " are provided.\n" + << " The last " << num-MaxNodes << " input nodes will be ignored.\n"; } } @@ -271,10 +272,11 @@ void FGFCSComponent::Clip(void) double range = vmax - vmin; if (range < 0.0) { - cerr << "Trying to clip with a max value (" << vmax << ") from " - << ClipMax->GetName() << " lower than the min value (" << vmin - << ") from " << ClipMin->GetName() << "." << endl - << "Clipping is ignored." << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::ERROR); + log << "Trying to clip with a max value (" << fixed << vmax << ") from " + << ClipMax->GetName() << " lower than the min value (" << vmin + << ") from " << ClipMin->GetName() << ".\n" + << "Clipping is ignored.\n"; return; } @@ -319,8 +321,8 @@ void FGFCSComponent::bind(Element* el, FGPropertyManager* PropertyManager) node->setDoubleValue(Output); } else { - cerr << el->ReadFrom() - << "Could not get or create property " << tmp << endl; + FGXMLLogging log(fcs->GetExec()->GetLogger(), el, LogLevel::ERROR); + log << "Could not get or create property " << tmp << "\n"; } } @@ -332,7 +334,7 @@ void FGFCSComponent::bind(Element* el, FGPropertyManager* PropertyManager) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -349,20 +351,22 @@ void FGFCSComponent::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { - cout << endl << " Loading Component \"" << Name - << "\" of type: " << Type << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + log << "\n Loading Component \"" << Name << fixed + << "\" of type: " << Type << "\n"; if (clip) { - cout << " Minimum limit: " << ClipMin->GetName() << endl; - cout << " Maximum limit: " << ClipMax->GetName() << endl; + log << " Minimum limit: " << ClipMin->GetName() << "\n"; + log << " Maximum limit: " << ClipMax->GetName() << "\n"; } - if (delay > 0) cout <<" Frame delay: " << delay - << " frames (" << delay*dt << " sec)" << endl; + if (delay > 0) log <<" Frame delay: " << delay << fixed + << setprecision(4) << " frames (" << delay*dt << " sec)\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGFCSComponent" << endl; - if (from == 1) cout << "Destroyed: FGFCSComponent" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGFCSComponent\n"; + if (from == 1) log << "Destroyed: FGFCSComponent\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGFCSFunction.cpp b/src/models/flight_control/FGFCSFunction.cpp index 64d516e88c..67e3f254db 100644 --- a/src/models/flight_control/FGFCSFunction.cpp +++ b/src/models/flight_control/FGFCSFunction.cpp @@ -40,6 +40,7 @@ INCLUDES #include "FGFCSFunction.h" #include "models/FGFCS.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" using namespace std; @@ -59,9 +60,9 @@ FGFCSFunction::FGFCSFunction(FGFCS* fcs, Element* element) if (function_element) function = new FGFunction(fcs->GetExec(), function_element); else { - cerr << element->ReadFrom() - << "FCS Function should contain a \"function\" element" << endl; - throw("Malformed FCS function specification."); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "FCS Function should contain a \"function\" element\n"; + throw BaseException(log.str()); } bind(element, fcs->GetPropertyManager().get()); @@ -101,7 +102,7 @@ bool FGFCSFunction::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -118,15 +119,17 @@ void FGFCSFunction::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); if (!InputNodes.empty()) - cout << " INPUT: " << InputNodes[0]->GetName() << endl; + log << " INPUT: " << InputNodes[0]->GetName() << "\n"; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getNameString() << endl; + log << " OUTPUT: " << node->getNameString() << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGFCSFunction" << endl; - if (from == 1) cout << "Destroyed: FGFCSFunction" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGFCSFunction\n"; + if (from == 1) log << "Destroyed: FGFCSFunction\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGFilter.cpp b/src/models/flight_control/FGFilter.cpp index a1a5fd6a68..ff49e28f2d 100644 --- a/src/models/flight_control/FGFilter.cpp +++ b/src/models/flight_control/FGFilter.cpp @@ -40,6 +40,7 @@ INCLUDES #include "FGFilter.h" #include "models/FGFCS.h" #include "math/FGParameterValue.h" +#include "input_output/FGLog.h" using namespace std; @@ -139,7 +140,10 @@ void FGFilter::CalculateDynamicFilters(void) cb = (2.0 - dt*C[1]) / denom; break; case eUnknown: - cerr << "Unknown filter type" << endl; + { + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::ERROR); + log << "Unknown filter type\n"; + } break; } @@ -199,7 +203,7 @@ bool FGFilter::Run(void) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -216,23 +220,25 @@ void FGFilter::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " INPUT: " << InputNodes[0]->GetName() << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + log << " INPUT: " << InputNodes[0]->GetName() << fixed << "\n"; for (int i=1; i < 7; i++) { if (!C[i]) break; - cout << " C[" << i << "]"; - if (!C[i]->IsConstant()) cout << " is the value of property"; - cout << ": "<< C[i]->GetName() << endl; + log << " C[" << i << "]"; + if (!C[i]->IsConstant()) log << " is the value of property"; + log << ": "<< C[i]->GetName() << "\n"; } for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getNameString() << endl; + log << " OUTPUT: " << node->getNameString() << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGFilter" << endl; - if (from == 1) cout << "Destroyed: FGFilter" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGFilter\n"; + if (from == 1) log << "Destroyed: FGFilter\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGGain.cpp b/src/models/flight_control/FGGain.cpp index cb8eb117a6..c12b18367b 100644 --- a/src/models/flight_control/FGGain.cpp +++ b/src/models/flight_control/FGGain.cpp @@ -41,6 +41,7 @@ INCLUDES #include "models/FGFCS.h" #include "math/FGParameterValue.h" #include "math/FGTable.h" +#include "input_output/FGLog.h" using namespace std; @@ -62,9 +63,8 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) if (Type == "PURE_GAIN") { if ( !element->FindElement("gain") ) { - cerr << element->ReadFrom() - << highint << " No GAIN specified (default: 1.0)" << normint - << endl; + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::ERROR); + log << LogFormat::BOLD << " No GAIN specified (default: 1.0)\n"; } } @@ -92,10 +92,10 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) OutMax = scale_element->FindElementValueAsNumber("max"); OutMin = scale_element->FindElementValueAsNumber("min"); } else { - cerr << scale_element->ReadFrom() - << "Maximum and minimum output values must be supplied for the " - "aerosurface scale component" << endl; - throw("Some inputs are missing."); + FGXMLLogging log(fcs->GetExec()->GetLogger(), scale_element, LogLevel::FATAL); + log << "Maximum and minimum output values must be supplied for the " + "aerosurface scale component\n"; + throw BaseException(log.str()); } ZeroCentered = true; Element* zero_centered = element->FindElement("zero_centered"); @@ -112,10 +112,9 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) if (element->FindElement("table")) { Table = new FGTable(PropertyManager, element->FindElement("table")); } else { - cerr << element->ReadFrom() - << "A table must be provided for the scheduled gain component" - << endl; - throw("Some inputs are missing."); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "A table must be provided for the scheduled gain component\n"; + throw BaseException(log.str()); } } @@ -179,7 +178,7 @@ bool FGGain::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -196,28 +195,30 @@ void FGGain::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " INPUT: " << InputNodes[0]->GetNameWithSign() << endl; - cout << " GAIN: " << Gain->GetName() << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + log << " INPUT: " << InputNodes[0]->GetNameWithSign() << "\n"; + log << " GAIN: " << Gain->GetName() << fixed << "\n"; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getNameString() << endl; + log << " OUTPUT: " << node->getNameString() << "\n"; if (Type == "AEROSURFACE_SCALE") { - cout << " In/Out Mapping:" << endl; - cout << " Input MIN: " << InMin << endl; - cout << " Input MAX: " << InMax << endl; - cout << " Output MIN: " << OutMin << endl; - cout << " Output MAX: " << OutMax << endl; + log << " In/Out Mapping:\n" << setprecision(4); + log << " Input MIN: " << InMin << "\n"; + log << " Input MAX: " << InMax << "\n"; + log << " Output MIN: " << OutMin << "\n"; + log << " Output MAX: " << OutMax << "\n"; } - if (Table != 0) { - cout << " Scheduled by table: " << endl; + if (Table) { + log << " Scheduled by table:\n"; Table->Print(); } } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGGain" << endl; - if (from == 1) cout << "Destroyed: FGGain" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGGain\n"; + if (from == 1) log << "Destroyed: FGGain\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGGyro.cpp b/src/models/flight_control/FGGyro.cpp index f144422b52..81cb6e3470 100644 --- a/src/models/flight_control/FGGyro.cpp +++ b/src/models/flight_control/FGGyro.cpp @@ -48,8 +48,9 @@ namespace JSBSim { CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ -FGGyro::FGGyro(FGFCS* fcs, Element* element) : FGSensor(fcs, element), - FGSensorOrientation(element) +FGGyro::FGGyro(FGFCS* fcs, Element* element) + : FGSensor(fcs, element), + FGSensorOrientation(element, fcs->GetExec()->GetLogger()) { Propagate = fcs->GetExec()->GetPropagate(); @@ -92,7 +93,7 @@ bool FGGyro::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -110,13 +111,15 @@ void FGGyro::Debug(int from) if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); if (from == 0) { // Constructor - cout << " Axis: " << ax[axis] << endl; + log << " Axis: " << ax[axis] << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGGyro" << endl; - if (from == 1) cout << "Destroyed: FGGyro" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGGyro\n"; + if (from == 1) log << "Destroyed: FGGyro\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGKinemat.cpp b/src/models/flight_control/FGKinemat.cpp index 2140cfda1f..579f80725e 100644 --- a/src/models/flight_control/FGKinemat.cpp +++ b/src/models/flight_control/FGKinemat.cpp @@ -40,6 +40,7 @@ INCLUDES #include "FGKinemat.h" #include "input_output/FGXMLElement.h" #include "models/FGFCS.h" +#include "input_output/FGLog.h" using namespace std; @@ -70,11 +71,10 @@ FGKinemat::FGKinemat(FGFCS* fcs, Element* element) } if (Detents.size() <= 1) { - stringstream s; - s << "Kinematic component " << Name - << " must have more than 1 setting element"; - cerr << element->ReadFrom() << endl << s.str() << endl; - throw BaseException(s.str()); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "\nKinematic component " << Name + << " must have more than 1 setting element\n"; + throw BaseException(log.str()); } bind(element, fcs->GetPropertyManager().get()); @@ -162,7 +162,7 @@ bool FGKinemat::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -178,20 +178,22 @@ void FGKinemat::Debug(int from) if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); if (from == 0) { // Constructor - cout << " INPUT: " << InputNodes[0]->GetName() << endl; - cout << " DETENTS: " << Detents.size() << endl; + log << " INPUT: " << InputNodes[0]->GetName() << "\n"; + log << " DETENTS: " << Detents.size() << fixed << setprecision(4) << "\n"; for (unsigned int i=0;igetNameString() << endl; - if (!DoScale) cout << " NOSCALE" << endl; + log << " OUTPUT: " << node->getNameString() << "\n"; + if (!DoScale) log << " NOSCALE\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGKinemat" << endl; - if (from == 1) cout << "Destroyed: FGKinemat" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGKinemat\n"; + if (from == 1) log << "Destroyed: FGKinemat\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGLinearActuator.cpp b/src/models/flight_control/FGLinearActuator.cpp index e0fb4c0d4c..6ce91bae50 100644 --- a/src/models/flight_control/FGLinearActuator.cpp +++ b/src/models/flight_control/FGLinearActuator.cpp @@ -40,6 +40,7 @@ INCLUDES #include "FGLinearActuator.h" #include "models/FGFCS.h" #include "math/FGParameterValue.h" +#include "input_output/FGLog.h" using namespace std; @@ -94,9 +95,10 @@ FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element) if (element->FindElement("module")) { module = element->FindElementValueAsNumber("module"); if (module < 0) { - cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() - << " parameter is forced from " << module - << " value to 1.0 value" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::WARN); + log << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() + << " parameter is forced from " << fixed << module + << " value to 1.0 value\n"; module = 1.0; } } @@ -104,9 +106,10 @@ FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element) if (element->FindElement("hysteresis")) { hysteresis = element->FindElementValueAsNumber("hysteresis"); if (hysteresis < 0) { - cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() - << " parameter is forced from " << hysteresis - << " value to 0.0 value" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::WARN); + log << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() + << " parameter is forced from " << fixed << hysteresis + << " value to 0.0 value\n"; hysteresis = 0.0; } } @@ -120,9 +123,10 @@ FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element) previousLagInput = previousLagOutput = 0.0; } else { if (lag < 0) { - cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() - << " parameter is forced from " - << lag << " value to 0.0 value" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::WARN); + log << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() + << " parameter is forced from " << fixed << lag + << " value to 0.0 value\n"; lag = 0; } } @@ -131,9 +135,10 @@ FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element) if (element->FindElement("rate")) { rate = element->FindElementValueAsNumber("rate"); if (rate <= 0 || rate > 1.0) { - cout << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() - << " parameter is forced from " << rate - << " value to 0.5 value" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::WARN); + log << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() + << " parameter is forced from " << fixed << rate + << " value to 0.5 value\n"; rate = 0.5; } } @@ -225,7 +230,7 @@ bool FGLinearActuator::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -241,26 +246,28 @@ void FGLinearActuator::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " INPUT: " << InputNodes[0]->GetNameWithSign() << endl; - cout << " inputMem: " << inputMem << endl; - cout << " bias: " << bias << endl; - cout << " module: " << module << endl; - cout << " hysteresis: " << hysteresis << endl; - cout << " rate: " << rate << endl; - cout << " versus: " << versus << endl; - cout << " direction: " << direction << endl; - cout << " countSpin: " << countSpin << endl; - cout << " Lag: " << lag << endl; - cout << " Gain: " << gain << endl; - cout << " set: " << set << endl; - cout << " reset: " << reset << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + log << " INPUT: " << InputNodes[0]->GetNameWithSign() << fixed << "\n"; + log << " inputMem: " << inputMem << "\n"; + log << " bias: " << bias << "\n"; + log << " module: " << module << "\n"; + log << " hysteresis: " << hysteresis << "\n"; + log << " rate: " << rate << "\n"; + log << " versus: " << versus << "\n"; + log << " direction: " << direction << "\n"; + log << " countSpin: " << countSpin << "\n"; + log << " Lag: " << lag << "\n"; + log << " Gain: " << gain << "\n"; + log << " set: " << set << "\n"; + log << " reset: " << reset << "\n"; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->GetName() << endl; + log << " OUTPUT: " << node->GetName() << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGLinearActuator" << endl; - if (from == 1) cout << "Destroyed: FGLinearActuator" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGLinearActuator\n"; + if (from == 1) log << "Destroyed: FGLinearActuator\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGMagnetometer.cpp b/src/models/flight_control/FGMagnetometer.cpp index 14218bde07..61f7a5d894 100644 --- a/src/models/flight_control/FGMagnetometer.cpp +++ b/src/models/flight_control/FGMagnetometer.cpp @@ -52,20 +52,21 @@ CLASS IMPLEMENTATION FGMagnetometer::FGMagnetometer(FGFCS* fcs, Element* element) - : FGSensor(fcs, element), FGSensorOrientation(element), counter(0), - INERTIAL_UPDATE_RATE(1000) + : FGSensor(fcs, element), + FGSensorOrientation(element, fcs->GetExec()->GetLogger()), + counter(0), INERTIAL_UPDATE_RATE(1000) { Propagate = fcs->GetExec()->GetPropagate(); MassBalance = fcs->GetExec()->GetMassBalance(); Inertial = fcs->GetExec()->GetInertial(); - + Element* location_element = element->FindElement("location"); if (location_element) vLocation = location_element->FindElementTripletConvertTo("IN"); else { - cerr << element->ReadFrom() - << "No location given for magnetometer. " << endl; - throw("Malformed magnetometer specification."); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "No location given for magnetometer.\n"; + throw BaseException(log.str()); } vRadius = MassBalance->StructuralToBody(vLocation); @@ -127,7 +128,7 @@ void FGMagnetometer::updateInertialMag(void) bool FGMagnetometer::Run(void ) { // There is no input assumed. This is a dedicated magnetic field sensor. - + vRadius = MassBalance->StructuralToBody(vLocation); updateInertialMag(); @@ -137,7 +138,7 @@ bool FGMagnetometer::Run(void ) // Allow for sensor orientation vMag = mT * vMag; - + Input = vMag(axis); ProcessSensorSignal(); @@ -155,7 +156,7 @@ bool FGMagnetometer::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -173,13 +174,15 @@ void FGMagnetometer::Debug(int from) if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); if (from == 0) { // Constructor - cout << " Axis: " << ax[axis] << endl; + log << " Axis: " << ax[axis] << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGMagnetometer" << endl; - if (from == 1) cout << "Destroyed: FGMagnetometer" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGMagnetometer\n"; + if (from == 1) log << "Destroyed: FGMagnetometer\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGPID.cpp b/src/models/flight_control/FGPID.cpp index 330b2a95ca..276b279cbc 100644 --- a/src/models/flight_control/FGPID.cpp +++ b/src/models/flight_control/FGPID.cpp @@ -38,6 +38,7 @@ INCLUDES #include "FGPID.h" #include "models/FGFCS.h" #include "math/FGParameterValue.h" +#include "input_output/FGLog.h" using namespace std; @@ -219,7 +220,7 @@ bool FGPID::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -235,16 +236,18 @@ void FGPID::Debug(int from) if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); if (from == 0) { // Constructor - cout << " INPUT: " << InputNodes[0]->GetNameWithSign() << endl; + log << " INPUT: " << InputNodes[0]->GetNameWithSign() << "\n"; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getNameString() << endl; + log << " OUTPUT: " << node->getNameString() << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGPID" << endl; - if (from == 1) cout << "Destroyed: FGPID" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGPID\n"; + if (from == 1) log << "Destroyed: FGPID\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGSensor.cpp b/src/models/flight_control/FGSensor.cpp index 820eb33dd4..8905a75787 100644 --- a/src/models/flight_control/FGSensor.cpp +++ b/src/models/flight_control/FGSensor.cpp @@ -40,6 +40,7 @@ INCLUDES #include "FGSensor.h" #include "models/FGFCS.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" using namespace std; @@ -102,8 +103,9 @@ FGSensor::FGSensor(FGFCS* fcs, Element* element) NoiseType = eAbsolute; } else { NoiseType = ePercent; - cerr << "Unknown noise type in sensor: " << Name << endl; - cerr << " defaulting to PERCENT." << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::ERROR); + log << "Unknown noise type in sensor: " << Name + << "\n defaulting to PERCENT.\n"; } string distribution = element->FindElement("noise")->GetAttributeValue("distribution"); if (distribution == "UNIFORM") { @@ -112,8 +114,9 @@ FGSensor::FGSensor(FGFCS* fcs, Element* element) DistributionType = eGaussian; } else { DistributionType = eUniform; - cerr << "Unknown random distribution type in sensor: " << Name << endl; - cerr << " defaulting to UNIFORM." << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::ERROR); + log << "Unknown random distribution type in sensor: " << Name + << "\n defaulting to UNIFORM.\n"; } } @@ -261,15 +264,15 @@ void FGSensor::bind(Element* el, FGPropertyManager* PropertyManager) PropertyManager->Tie( tmp_low, this, &FGSensor::GetFailLow, &FGSensor::SetFailLow); PropertyManager->Tie( tmp_high, this, &FGSensor::GetFailHigh, &FGSensor::SetFailHigh); PropertyManager->Tie( tmp_stuck, this, &FGSensor::GetFailStuck, &FGSensor::SetFailStuck); - + if (!quant_property.empty()) { if (quant_property.find("/") == string::npos) { // not found string qprop = "fcs/" + PropertyManager->mkPropertyName(quant_property, true); FGPropertyNode* node = PropertyManager->GetNode(qprop, true); if (node->isTied()) { - cerr << el->ReadFrom() - << "Property " << tmp << " has already been successfully bound (late)." << endl; - throw("Failed to bind the property to an existing already tied node."); + FGXMLLogging log(fcs->GetExec()->GetLogger(), el, LogLevel::FATAL); + log << "Property " << tmp << " has already been successfully bound (late).\n"; + throw BaseException(log.str()); } else PropertyManager->Tie(qprop, this, &FGSensor::GetQuantized); @@ -286,7 +289,7 @@ void FGSensor::bind(Element* el, FGPropertyManager* PropertyManager) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -302,45 +305,48 @@ void FGSensor::Debug(int from) if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); if (from == 0) { // Constructor if (!InputNodes.empty()) - cout << " INPUT: " << InputNodes[0]->GetNameWithSign() << endl; + log << " INPUT: " << InputNodes[0]->GetNameWithSign() << fixed + << setprecision(4) << "\n"; if (bits != 0) { if (quant_property.empty()) - cout << " Quantized output" << endl; + log << " Quantized output\n"; else - cout << " Quantized output (property: " << quant_property << ")" << endl; + log << " Quantized output (property: " << quant_property << ")\n"; - cout << " Bits: " << bits << endl; - cout << " Min value: " << min << endl; - cout << " Max value: " << max << endl; - cout << " (span: " << span << ", granularity: " << granularity << ")" << endl; + log << " Bits: " << bits << "\n"; + log << " Min value: " << min << "\n"; + log << " Max value: " << max << "\n"; + log << " (span: " << span << ", granularity: " << granularity << ")\n"; } - if (bias != 0.0) cout << " Bias: " << bias << endl; - if (gain != 0.0) cout << " Gain: " << gain << endl; - if (drift_rate != 0) cout << " Sensor drift rate: " << drift_rate << endl; - if (lag != 0) cout << " Sensor lag: " << lag << endl; + if (bias != 0.0) log << " Bias: " << bias << " \n"; + if (gain != 0.0) log << " Gain: " << gain << " \n"; + if (drift_rate != 0) log << " Sensor drift rate: " << drift_rate << " \n"; + if (lag != 0) log << " Sensor lag: " << lag << " \n"; if (noise_variance != 0) { if (NoiseType == eAbsolute) { - cout << " Noise variance (absolute): " << noise_variance << endl; + log << " Noise variance (absolute): " << noise_variance << " \n"; } else if (NoiseType == ePercent) { - cout << " Noise variance (percent): " << noise_variance << endl; + log << " Noise variance (percent): " << noise_variance << " \n"; } else { - cout << " Noise variance type is invalid" << endl; + log << " Noise variance type is invalid\n"; } if (DistributionType == eUniform) { - cout << " Random noise is uniformly distributed." << endl; + log << " Random noise is uniformly distributed.\n"; } else if (DistributionType == eGaussian) { - cout << " Random noise is gaussian distributed." << endl; + log << " Random noise is gaussian distributed.\n"; } } for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getNameString() << endl; + log << " OUTPUT: " << node->getNameString() << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGSensor" << endl; - if (from == 1) cout << "Destroyed: FGSensor" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGSensor\n"; + if (from == 1) log << "Destroyed: FGSensor\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/flight_control/FGSensorOrientation.h b/src/models/flight_control/FGSensorOrientation.h index 0c62034d05..21f387743b 100644 --- a/src/models/flight_control/FGSensorOrientation.h +++ b/src/models/flight_control/FGSensorOrientation.h @@ -41,6 +41,7 @@ INCLUDES #include "input_output/FGXMLElement.h" #include "math/FGColumnVector3.h" #include "math/FGMatrix33.h" +#include "input_output/FGLog.h" #include @@ -69,7 +70,7 @@ CLASS DECLARATION class FGSensorOrientation : public FGJSBBase { public: - FGSensorOrientation(Element* element) + FGSensorOrientation(Element* element, std::shared_ptr logger) { Element* orient_element = element->FindElement("orientation"); if (orient_element) vOrient = orient_element->FindElementTripletConvertTo("RAD"); @@ -78,7 +79,7 @@ class FGSensorOrientation : public FGJSBBase Element* axis_element = element->FindElement("axis"); if (axis_element) { - std::string sAxis = element->FindElementValue("axis"); + std::string sAxis = axis_element->GetDataLine(); if (sAxis == "X" || sAxis == "x") { axis = 1; } else if (sAxis == "Y" || sAxis == "y") { @@ -88,16 +89,15 @@ class FGSensorOrientation : public FGJSBBase } } - if (!axis) { - std::cerr << " Incorrect/no axis specified for this sensor; assuming X axis" << std::endl; + if (axis == 0) { + FGXMLLogging log(logger, element, LogLevel::WARN); + log << " Incorrect/no axis specified for this sensor; assuming X axis\n"; axis = 1; } CalculateTransformMatrix(); } -// ~FGSensorOrientation(); - protected: FGColumnVector3 vOrient; FGMatrix33 mT; diff --git a/src/models/flight_control/FGSummer.cpp b/src/models/flight_control/FGSummer.cpp index 4e43666a8a..9c81b49053 100644 --- a/src/models/flight_control/FGSummer.cpp +++ b/src/models/flight_control/FGSummer.cpp @@ -40,6 +40,7 @@ INCLUDES #include "FGSummer.h" #include "models/FGFCS.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" using namespace std; @@ -92,7 +93,7 @@ bool FGSummer::Run(void) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -108,18 +109,20 @@ void FGSummer::Debug(int from) if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); if (from == 0) { // Constructor - cout << " INPUTS: " << endl; + log << " INPUTS: " << fixed << "\n"; for (auto node: InputNodes) - cout << " " << node->GetNameWithSign() << endl; - if (Bias != 0.0) cout << " Bias: " << Bias << endl; + log << " " << node->GetNameWithSign() << "\n"; + if (Bias != 0.0) log << " Bias: " << Bias << "\n"; for (auto node: OutputNodes) - cout << " OUTPUT: " << node->GetName() << endl; + log << " OUTPUT: " << node->GetName() << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGSummer" << endl; - if (from == 1) cout << "Destroyed: FGSummer" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGSummer\n"; + if (from == 1) log << "Destroyed: FGSummer\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } @@ -134,4 +137,3 @@ void FGSummer::Debug(int from) } } //namespace JSBSim - diff --git a/src/models/flight_control/FGSwitch.cpp b/src/models/flight_control/FGSwitch.cpp index a1e9f731cc..380265a8b7 100644 --- a/src/models/flight_control/FGSwitch.cpp +++ b/src/models/flight_control/FGSwitch.cpp @@ -64,6 +64,7 @@ INCLUDES #include "FGSwitch.h" #include "models/FGFCS.h" #include "math/FGCondition.h" +#include "input_output/FGLog.h" using namespace std; @@ -83,26 +84,39 @@ FGSwitch::FGSwitch(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) // definition for a sample-and-hold Element* test_element = element->FindElement("default"); if (test_element) { - current_test = new Test; - value = test_element->GetAttributeValue("value"); - current_test->setTestValue(value, Name, PropertyManager, test_element); - current_test->Default = true; - if (delay > 0 && is_number(trim(value))) { // If there is a delay, initialize the - double v = atof_locale_c(value); - for (unsigned int i=0; iGetAttributeValue("value"); + current_test->setTestValue(value, Name, PropertyManager, test_element); + current_test->Default = true; + if (delay > 0 && is_number(trim(value))) { // If there is a delay, initialize the + double v = atof_locale_c(value); + for (unsigned int i=0; iGetExec()->GetLogger(), test_element, LogLevel::ERROR); + log << e.what() << "\n" + << " Default value IGNORED.\n"; } - tests.push_back(current_test); } test_element = element->FindElement("test"); while (test_element) { - current_test = new Test; - current_test->condition = new FGCondition(test_element, PropertyManager); - value = test_element->GetAttributeValue("value"); - current_test->setTestValue(value, Name, PropertyManager, test_element); - tests.push_back(current_test); + try { + current_test = new Test; + current_test->condition = new FGCondition(test_element, PropertyManager); + value = test_element->GetAttributeValue("value"); + current_test->setTestValue(value, Name, PropertyManager, test_element); + tests.push_back(current_test); + } catch (const BaseException& e) { + FGXMLLogging log(fcs->GetExec()->GetLogger(), test_element, LogLevel::ERROR); + log << e.what() << "\n" + << " Test IGNORED.\n"; + } + test_element = element->FindNextElement("test"); } @@ -147,7 +161,7 @@ bool FGSwitch::Run(void ) break; } } - + if (!pass) Output = default_output; if (delay != 0) Delay(); @@ -177,7 +191,7 @@ void FGSwitch::VerifyProperties(void) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -194,25 +208,27 @@ void FGSwitch::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); unsigned int i = 0; for (auto test: tests) { if (test->Default) { - cout << " Switch default value is: " << test->GetOutputName(); + log << " Switch default value is: " << test->GetOutputName(); } else { - cout << " Switch takes test " << i << " value (" << test->GetOutputName() << ")" << endl; + log << " Switch takes test " << i << " value (" << test->GetOutputName() << ")\n"; test->condition->PrintCondition(" "); } - cout << endl; + log << "\n"; ++i; } for (auto node: OutputNodes) - cout << " OUTPUT: " << node->getNameString() << endl; + log << " OUTPUT: " << node->getNameString() << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGSwitch" << endl; - if (from == 1) cout << "Destroyed: FGSwitch" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGSwitch\n"; + if (from == 1) log << "Destroyed: FGSwitch\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } @@ -227,4 +243,3 @@ void FGSwitch::Debug(int from) } } //namespace JSBSim - diff --git a/src/models/flight_control/FGSwitch.h b/src/models/flight_control/FGSwitch.h index fd78981a3b..a9c454e748 100644 --- a/src/models/flight_control/FGSwitch.h +++ b/src/models/flight_control/FGSwitch.h @@ -156,11 +156,10 @@ class FGSwitch : public FGFCSComponent void setTestValue(const std::string &value, const std::string &Name, std::shared_ptr pm, Element* el) { - if (value.empty()) { - std::cerr << "No VALUE supplied for switch component: " << Name - << std::endl; - } else + if (!value.empty()) OutputValue = new FGParameterValue(value, pm, el); + else + throw BaseException("No VALUE supplied for switch component: " + Name); } std::string GetOutputName(void) const {return OutputValue->GetName();} diff --git a/src/models/flight_control/FGWaypoint.cpp b/src/models/flight_control/FGWaypoint.cpp index 84debc62d5..be600a2879 100644 --- a/src/models/flight_control/FGWaypoint.cpp +++ b/src/models/flight_control/FGWaypoint.cpp @@ -43,6 +43,7 @@ INCLUDES #include "models/FGFCS.h" #include "models/FGInertial.h" #include "initialization/FGInitialCondition.h" +#include "input_output/FGLog.h" using namespace std; @@ -77,10 +78,9 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) } } } else { - cerr << element->ReadFrom() << endl - << "Target latitude is required for waypoint component: " << Name - << endl; - throw("Malformed waypoint definition"); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "Target latitude is required for waypoint component: " << Name << "\n"; + throw BaseException(log.str()); } if (element->FindElement("target_longitude") ) { @@ -92,10 +92,9 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) } } } else { - cerr << element->ReadFrom() << endl - << "Target longitude is required for waypoint component: " << Name - << endl; - throw("Malformed waypoint definition"); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "Target longitude is required for waypoint component: " << Name << "\n"; + throw BaseException(log.str()); } if (element->FindElement("source_latitude") ) { @@ -107,10 +106,9 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) } } } else { - cerr << element->ReadFrom() << endl - << "Source latitude is required for waypoint component: " << Name - << endl; - throw("Malformed waypoint definition"); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "Source latitude is required for waypoint component: " << Name << "\n"; + throw BaseException(log.str()); } if (element->FindElement("source_longitude") ) { @@ -122,10 +120,9 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) } } } else { - cerr << element->ReadFrom() << endl - << "Source longitude is required for waypoint component: " << Name - << endl; - throw("Malformed waypoint definition"); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "Source longitude is required for waypoint component: " << Name << "\n"; + throw BaseException(log.str()); } unit = element->GetAttributeValue("unit"); @@ -134,10 +131,9 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) if (unit == "DEG") eUnit = eDeg; else if (unit == "RAD") eUnit = eRad; else { - cerr << element->ReadFrom() << endl - << "Unknown unit " << unit << " in HEADING waypoint component, " - << Name << endl; - throw("Malformed waypoint definition"); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "Unknown unit " << unit << " in HEADING waypoint component, " << "\n"; + throw BaseException(log.str()); } } else { eUnit = eRad; // Default is radians if unspecified @@ -147,10 +143,10 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) if (unit == "FT") eUnit = eFeet; else if (unit == "M") eUnit = eMeters; else { - cerr << element->ReadFrom() << endl - << "Unknown unit " << unit << " in DISTANCE waypoint component, " - << Name << endl; - throw("Malformed waypoint definition"); + FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::FATAL); + log << "Unknown unit " << unit << " in DISTANCE waypoint component, " + << Name << "\n"; + throw BaseException(log.str()); } } else { eUnit = eFeet; // Default is feet if unspecified @@ -179,19 +175,19 @@ bool FGWaypoint::Run(void ) source.SetPositionGeodetic(source_longitude_rad, source_latitude_rad, 0.0); if (fabs(target_latitude_rad) > M_PI/2.0) { - cerr << endl; - cerr << "Target latitude in waypoint \"" << Name << "\" must be less than or equal to 90 degrees." << endl; - cerr << "(is longitude being mistakenly supplied?)" << endl; - cerr << endl; - throw("Waypoint target latitude exceeded 90 degrees."); + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::FATAL); + log << "\nTarget latitude in waypoint \"" << Name + << "\" must be less than or equal to 90 degrees.\n" + << "(is longitude being mistakenly supplied?)\n\n"; + throw BaseException(log.str()); } if (fabs(source_latitude_rad) > M_PI/2.0) { - cerr << endl; - cerr << "Source latitude in waypoint \"" << Name << "\" must be less than or equal to 90 degrees." << endl; - cerr << "(is longitude being mistakenly supplied?)" << endl; - cerr << endl; - throw("Source latitude exceeded 90 degrees."); + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::FATAL); + log << "\nSource latitude in waypoint \"" << Name + << "\" must be less than or equal to 90 degrees.\n" + << "(is longitude being mistakenly supplied?)\n\n"; + throw BaseException(log.str()); } if (WaypointType == eHeading) { // Calculate Heading @@ -225,7 +221,7 @@ bool FGWaypoint::Run(void ) // variable is not set, debug_lvl is set to 1 internally // 0: This requests JSBSim not to output any messages // whatsoever. -// 1: This value explicity requests the normal JSBSim +// 1: This value explicitly requests the normal JSBSim // startup messages // 2: This value asks for a message to be printed out when // a class is instantiated @@ -245,8 +241,9 @@ void FGWaypoint::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGWaypoint" << endl; - if (from == 1) cout << "Destroyed: FGWaypoint" << endl; + FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGWaypoint\n"; + if (from == 1) log << "Destroyed: FGWaypoint\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects }