From eeb396f32b480ab50ade46f11790b7aefaaab22a Mon Sep 17 00:00:00 2001 From: Bertrand Coconnier Date: Sun, 27 Oct 2024 17:49:47 +0100 Subject: [PATCH] Some migration to the new logging system. --- src/models/propulsion/FGForce.cpp | 12 +-- src/models/propulsion/FGNozzle.cpp | 20 +++-- src/models/propulsion/FGPropeller.cpp | 65 ++++++-------- src/models/propulsion/FGRotor.cpp | 120 ++++++++++++++------------ src/models/propulsion/FGThruster.cpp | 12 ++- 5 files changed, 121 insertions(+), 108 deletions(-) diff --git a/src/models/propulsion/FGForce.cpp b/src/models/propulsion/FGForce.cpp index f7f82d09cd..e1a3860639 100644 --- a/src/models/propulsion/FGForce.cpp +++ b/src/models/propulsion/FGForce.cpp @@ -42,6 +42,7 @@ moments due to the difference between the point of application and the cg. #include "FGForce.h" #include "FGFDMExec.h" #include "models/FGAuxiliary.h" +#include "input_output/FGLog.h" using namespace std; @@ -108,9 +109,9 @@ const FGMatrix33& FGForce::Transform(void) const return mT; default: { - const string s("Unrecognized tranform requested from FGForce::Transform()"); - cout << s << endl; - throw BaseException(s); + FGLogging log(fdmex->GetLogger(), LogLevel::FATAL); + log << "Unrecognized tranform requested from FGForce::Transform()\n"; + throw BaseException(log.str()); } } } @@ -185,8 +186,9 @@ void FGForce::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGForce" << endl; - if (from == 1) cout << "Destroyed: FGForce" << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGForce\n"; + if (from == 1) log << "Destroyed: FGForce\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/propulsion/FGNozzle.cpp b/src/models/propulsion/FGNozzle.cpp index 9765339605..2c86b49020 100644 --- a/src/models/propulsion/FGNozzle.cpp +++ b/src/models/propulsion/FGNozzle.cpp @@ -40,7 +40,9 @@ INCLUDES #include #include "FGNozzle.h" +#include "FGFDMExec.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" using namespace std; @@ -52,14 +54,14 @@ CLASS IMPLEMENTATION FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) - : FGThruster(FDMExec, nozzle_element, num) + : FGThruster(FDMExec, nozzle_element, num) { if (nozzle_element->FindElement("area")) Area = nozzle_element->FindElementValueAsNumberConvertTo("area", "FT2"); else { - const string s("Fatal Error: Nozzle exit area must be given in nozzle config file."); - cerr << s << endl; - throw BaseException(s); + FGXMLLogging log(fdmex->GetLogger(), nozzle_element, LogLevel::FATAL); + log << "Fatal Error: Nozzle exit area must be given in nozzle config file.\n"; + throw BaseException(log.str()); } Thrust = 0; @@ -133,13 +135,15 @@ void FGNozzle::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << " Nozzle Name: " << Name << endl; - cout << " Nozzle Exit Area = " << Area << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + log << " Nozzle Name: " << Name << "\n"; + log << " Nozzle Exit Area = " << Area << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGNozzle" << endl; - if (from == 1) cout << "Destroyed: FGNozzle" << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGNozzle\n"; + if (from == 1) log << "Destroyed: FGNozzle\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/propulsion/FGPropeller.cpp b/src/models/propulsion/FGPropeller.cpp index aaa35f51ca..875b2550a2 100644 --- a/src/models/propulsion/FGPropeller.cpp +++ b/src/models/propulsion/FGPropeller.cpp @@ -41,6 +41,7 @@ INCLUDES #include "FGFDMExec.h" #include "FGPropeller.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" using namespace std; @@ -109,14 +110,19 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num) } else if (name == "CP_MACH") { CpMach = new FGTable(PropertyManager, table_element); } else { - cerr << "Unknown table type: " << name << " in propeller definition." << endl; + FGXMLLogging log(fdmex->GetLogger(), table_element, LogLevel::ERROR); + log << "Unknown table type: " << name << " in propeller definition.\n"; } } catch (std::string& str) { - throw("Error loading propeller table:" + name + ". " + str); + FGXMLLogging log(fdmex->GetLogger(), table_element, LogLevel::ERROR); + log << "Error loading propeller table:" << name << ". " << str << "\n"; + throw BaseException(log.str()); } } if( (cPower == 0) || (cThrust == 0)){ - cerr << "Propeller configuration must contain C_THRUST and C_POWER tables!" << endl; + FGXMLLogging log(fdmex->GetLogger(), prop_element, LogLevel::ERROR); + log << "Propeller configuration must contain C_THRUST and C_POWER tables!\n"; + throw BaseException(log.str()); } local_element = prop_element->GetParent()->FindElement("sense"); @@ -129,7 +135,9 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num) P_Factor = local_element->GetDataAsNumber(); } if (P_Factor < 0) { - cerr << "P-Factor value in propeller configuration file must be greater than zero" << endl; + FGXMLLogging log(fdmex->GetLogger(), local_element, LogLevel::ERROR); + log << "P-Factor value in propeller configuration file must be greater than zero\n"; + throw BaseException(log.str()); } if (prop_element->FindElement("ct_factor")) SetCtFactor( prop_element->FindElementValueAsNumber("ct_factor") ); @@ -249,12 +257,12 @@ double FGPropeller::Calculate(double EnginePower) // Since Thrust and Vel can both be negative we need to adjust this formula // To handle sign (direction) separately from magnitude. double Vel2sum = Vel*abs(Vel) + 2.0*Thrust/(rho*Area); - + if( Vel2sum > 0.0) Vinduced = 0.5 * (-Vel + sqrt(Vel2sum)); else Vinduced = 0.5 * (-Vel - sqrt(-Vel2sum)); - + // P-factor is simulated by a shift of the acting location of the thrust. // The shift is a multiple of the angle between the propeller shaft axis // and the relative wind that goes through the propeller disk. @@ -359,7 +367,7 @@ double FGPropeller::GetPowerRequired(void) if (CpMach) cPReq *= CpMach->GetValue(HelicalTipMach); double RPS = RPM / 60.0; - double local_RPS = RPS < 0.01 ? 0.01 : RPS; + double local_RPS = RPS < 0.01 ? 0.01 : RPS; PowerRequired = cPReq*local_RPS*local_RPS*local_RPS*D5*in.Density; @@ -439,39 +447,22 @@ void FGPropeller::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << "\n Propeller Name: " << Name << endl; - cout << " IXX = " << Ixx << endl; - cout << " Diameter = " << Diameter << " ft." << endl; - cout << " Number of Blades = " << numBlades << endl; - cout << " Gear Ratio = " << GearRatio << endl; - cout << " Minimum Pitch = " << MinPitch << endl; - cout << " Maximum Pitch = " << MaxPitch << endl; - cout << " Minimum RPM = " << MinRPM << endl; - cout << " Maximum RPM = " << MaxRPM << endl; -// Tables are being printed elsewhere... -// cout << " Thrust Coefficient: " << endl; -// cThrust->Print(); -// cout << " Power Coefficient: " << endl; -// cPower->Print(); -// cout << " Mach Thrust Coefficient: " << endl; -// if(CtMach) -// { -// CtMach->Print(); -// } else { -// cout << " NONE" << endl; -// } -// cout << " Mach Power Coefficient: " << endl; -// if(CpMach) -// { -// CpMach->Print(); -// } else { -// cout << " NONE" << endl; -// } + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + log << "\n Propeller Name: " << Name << "\n"; + log << " IXX = " << Ixx << "\n"; + log << " Diameter = " << Diameter << " ft." << "\n"; + log << " Number of Blades = " << numBlades << "\n"; + log << " Gear Ratio = " << GearRatio << "\n"; + log << " Minimum Pitch = " << MinPitch << "\n"; + log << " Maximum Pitch = " << MaxPitch << "\n"; + log << " Minimum RPM = " << MinRPM << "\n"; + log << " Maximum RPM = " << MaxRPM << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGPropeller" << endl; - if (from == 1) cout << "Destroyed: FGPropeller" << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGPropeller\n"; + if (from == 1) log << "Destroyed: FGPropeller\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/propulsion/FGRotor.cpp b/src/models/propulsion/FGRotor.cpp index c0de292eb3..3361a5fbd5 100644 --- a/src/models/propulsion/FGRotor.cpp +++ b/src/models/propulsion/FGRotor.cpp @@ -31,12 +31,12 @@ HISTORY -------------------------------------------------------------------------------- 08/24/00 JSB Created 01/01/10 T.Kreitler test implementation -11/15/10 T.Kreitler treated flow solver bug, flow and torque calculations +11/15/10 T.Kreitler treated flow solver bug, flow and torque calculations simplified, tiploss influence removed from flapping angles 01/10/11 T.Kreitler changed to single rotor model 03/06/11 T.Kreitler added brake, clutch, and experimental free-wheeling-unit, reasonable estimate for inflowlag -02/05/12 T.Kreitler brake, clutch, and FWU now in FGTransmission, +02/05/12 T.Kreitler brake, clutch, and FWU now in FGTransmission, downwash angles relate to shaft orientation %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -50,10 +50,8 @@ INCLUDES #include "models/FGMassBalance.h" #include "models/FGPropulsion.h" // to get the GearRatio from a linked rotor #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" -using std::cerr; -using std::cout; -using std::endl; using std::string; using std::ostringstream; @@ -75,7 +73,7 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) : FGThruster(exec, rotor_element, num), rho(0.002356), // environment Radius(0.0), BladeNum(0), // configuration parameters - Sense(1.0), NominalRPM(0.0), MinimalRPM(0.0), MaximalRPM(0.0), + Sense(1.0), NominalRPM(0.0), MinimalRPM(0.0), MaximalRPM(0.0), ExternalRPM(0), RPMdefinition(0), ExtRPMsource(NULL), SourceGearRatio(1.0), BladeChord(0.0), LiftCurveSlope(0.0), BladeTwist(0.0), HingeOffset(0.0), BladeFlappingMoment(0.0), BladeMassMoment(0.0), PolarMoment(0.0), @@ -107,7 +105,7 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) for (int i=0; i<5; i++) R[i] = 0.0; for (int i=0; i<5; i++) B[i] = 0.0; - // get positions + // get positions thruster_element = rotor_element->GetParent()->FindElement("sense"); if (thruster_element) { double s = thruster_element->GetDataAsNumber(); @@ -124,14 +122,16 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) if (thruster_element) { location = thruster_element->FindElementTripletConvertTo("IN"); } else { - cerr << "No thruster location found." << endl; + FGXMLLogging log(exec->GetLogger(), rotor_element, LogLevel::ERROR); + log << "No thruster location found.\n"; } thruster_element = rotor_element->GetParent()->FindElement("orient"); if (thruster_element) { orientation = thruster_element->FindElementTripletConvertTo("RAD"); } else { - cerr << "No thruster orientation found." << endl; + FGXMLLogging log(exec->GetLogger(), rotor_element, LogLevel::ERROR); + log << "No thruster orientation found.\n"; } SetLocation(location); @@ -140,7 +140,8 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) // wire controls ControlMap = eMainCtrl; - if (rotor_element->FindElement("controlmap")) { + Element* controlmap_el = rotor_element->FindElement("controlmap"); + if (controlmap_el) { string cm = rotor_element->FindElementValue("controlmap"); cm = to_upper(cm); if (cm == "TAIL") { @@ -148,12 +149,14 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) } else if (cm == "TANDEM") { ControlMap = eTandemCtrl; } else { - cerr << "# found unknown controlmap: '" << cm << "' using main rotor config." << endl; + FGXMLLogging log(exec->GetLogger(), controlmap_el, LogLevel::ERROR); + log << "# found unknown controlmap: '" << cm << "' using main rotor config.\n"; } } // ExternalRPM -- is the RPM dictated ? - if (rotor_element->FindElement("ExternalRPM")) { + Element* extrpm_el = rotor_element->FindElement("ExternalRPM"); + if (extrpm_el) { ExternalRPM = 1; SourceGearRatio = 1.0; RPMdefinition = (int) rotor_element->FindElementValueAsNumber("ExternalRPM"); @@ -169,7 +172,9 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) } } if (RPMdefinition != rdef) { - cerr << "# discarded given RPM source (" << rdef << ") and switched to external control (-1)." << endl; + FGXMLLogging log(exec->GetLogger(), extrpm_el, LogLevel::ERROR); + log << "# discarded given RPM source (" << rdef + << ") and switched to external control (-1).\n"; } } @@ -248,8 +253,9 @@ double FGRotor::ConfigValueConv( Element* el, const string& ename, double defaul } } else { if (tell) { - cerr << pname << ": missing element '" << ename << - "' using estimated value: " << default_val << endl; + FGXMLLogging log(fdmex->GetLogger(), el, LogLevel::ERROR); + log << pname << ": missing element '" << ename + << "' using estimated value: " << default_val << "\n"; } } @@ -277,9 +283,9 @@ double FGRotor::Configure(Element* rotor_element) Radius = 0.5 * ConfigValueConv(rotor_element, "diameter", 42.0, "FT", yell); Radius = Constrain(1e-3, Radius, 1e9); - + BladeNum = (int) ConfigValue(rotor_element, "numblades", 3 , yell); - + GearRatio = ConfigValue(rotor_element, "gearratio", 1.0, yell); GearRatio = Constrain(1e-9, GearRatio, 1e9); @@ -304,7 +310,7 @@ double FGRotor::Configure(Element* rotor_element) HingeOffset = ConfigValueConv(rotor_element, "hingeoffset", 0.05 * Radius, "FT" ); estimate = sqr(BladeChord) * sqr(Radius - HingeOffset) * 0.57; - BladeFlappingMoment = ConfigValueConv(rotor_element, "flappingmoment", estimate, "SLUG*FT2"); + BladeFlappingMoment = ConfigValueConv(rotor_element, "flappingmoment", estimate, "SLUG*FT2"); BladeFlappingMoment = Constrain(1e-9, BladeFlappingMoment, 1e9); // guess mass from moment of a thin stick, and multiply by the blades cg distance @@ -353,7 +359,7 @@ double FGRotor::Configure(Element* rotor_element) // calculate control-axes components of total airspeed at the hub. // sets rotor orientation angle (beta) as side effect. /SH79/ eqn(19-22) -FGColumnVector3 FGRotor::hub_vel_body2ca( const FGColumnVector3 &uvw, +FGColumnVector3 FGRotor::hub_vel_body2ca( const FGColumnVector3 &uvw, const FGColumnVector3 &pqr, double a_ic, double b_ic) { @@ -415,7 +421,7 @@ void FGRotor::calc_flow_and_thrust( double theta_0, double Uw, double Ww, mu = Uw/(Omega*Radius); // /SH79/ eqn(24) if (mu > 0.7) mu = 0.7; mu2 = sqr(mu); - + ct_t0 = (1.0/3.0*B[3] + 1.0/2.0 * TipLossB*mu2 - 4.0/(9.0*M_PI) * mu*mu2 ) * theta_0; ct_t1 = (1.0/4.0*B[4] + 1.0/4.0 * B[2]*mu2) * BladeTwist; @@ -448,7 +454,7 @@ void FGRotor::calc_flow_and_thrust( double theta_0, double Uw, double Ww, //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// Two blade teetering rotors are often 'preconed' to a fixed angle, but the +// Two blade teetering rotors are often 'preconed' to a fixed angle, but the // calculated value is pretty close to the real one. /SH79/ eqn(29) void FGRotor::calc_coning_angle(double theta_0) @@ -473,7 +479,7 @@ void FGRotor::calc_flapping_angles(double theta_0, const FGColumnVector3 &pqr_fu double mu2_2 = sqr(mu)/2.0; double t075 = theta_0 + 0.75 * BladeTwist; // common approximation for rectangular blades - + a_1 = 1.0/(1.0 - mu2_2) * ( (2.0*lambda + (8.0/3.0)*t075)*mu + pqr_fus_w(eP)/Omega @@ -573,7 +579,7 @@ FGColumnVector3 FGRotor::body_forces(double a_ic, double b_ic) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -// calculates the additional moments due to hinge offset and handles +// calculates the additional moments due to hinge offset and handles // torque and sense FGColumnVector3 FGRotor::body_moments(double a_ic, double b_ic) @@ -770,13 +776,15 @@ bool FGRotor::bindmodel(FGPropertyManager* PropertyManager) property_name = ipn + "/rotor-rpm"; ExtRPMsource = PropertyManager->GetNode(property_name, false); if (! ExtRPMsource) { - cerr << "# Warning: Engine number " << EngineNum << "." << endl; - cerr << "# No 'rotor-rpm' property found for engine " << RPMdefinition << "." << endl; - cerr << "# Please check order of engine definitons." << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); + log << "# Warning: Engine number " << EngineNum << ".\n"; + log << "# No 'rotor-rpm' property found for engine " << RPMdefinition << ".\n"; + log << "# Please check order of engine definitons.\n"; } } else { - cerr << "# Engine number " << EngineNum; - cerr << ", given ExternalRPM value '" << RPMdefinition << "' unhandled." << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); + log << "# Engine number " << EngineNum; + log << ", given ExternalRPM value '" << RPMdefinition << "' unhandled.\n"; } } @@ -836,50 +844,52 @@ void FGRotor::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - cout << "\n Rotor Name: " << Name << endl; - cout << " Diameter = " << 2.0 * Radius << " ft." << endl; - cout << " Number of Blades = " << BladeNum << endl; - cout << " Gear Ratio = " << GearRatio << endl; - cout << " Sense = " << Sense << endl; - cout << " Nominal RPM = " << NominalRPM << endl; - cout << " Minimal RPM = " << MinimalRPM << endl; - cout << " Maximal RPM = " << MaximalRPM << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + log << "\n Rotor Name: " << Name << "\n"; + log << " Diameter = " << 2.0 * Radius << " ft." << "\n"; + log << " Number of Blades = " << BladeNum << "\n"; + log << " Gear Ratio = " << GearRatio << "\n"; + log << " Sense = " << Sense << "\n"; + log << " Nominal RPM = " << NominalRPM << "\n"; + log << " Minimal RPM = " << MinimalRPM << "\n"; + log << " Maximal RPM = " << MaximalRPM << "\n"; if (ExternalRPM) { if (RPMdefinition == -1) { - cout << " RPM is controlled externally" << endl; + log << " RPM is controlled externally\n"; } else { - cout << " RPM source set to thruster " << RPMdefinition << endl; + log << " RPM source set to thruster " << RPMdefinition << "\n"; } } - cout << " Blade Chord = " << BladeChord << endl; - cout << " Lift Curve Slope = " << LiftCurveSlope << endl; - cout << " Blade Twist = " << BladeTwist << endl; - cout << " Hinge Offset = " << HingeOffset << endl; - cout << " Blade Flapping Moment = " << BladeFlappingMoment << endl; - cout << " Blade Mass Moment = " << BladeMassMoment << endl; - cout << " Polar Moment = " << PolarMoment << endl; - cout << " Inflow Lag = " << InflowLag << endl; - cout << " Tip Loss = " << TipLossB << endl; - cout << " Lock Number = " << LockNumberByRho * 0.002356 << " (SL)" << endl; - cout << " Solidity = " << Solidity << endl; - cout << " Max Brake Power = " << MaxBrakePower/hptoftlbssec << " HP" << endl; - cout << " Gear Loss = " << GearLoss/hptoftlbssec << " HP" << endl; - cout << " Gear Moment = " << GearMoment << endl; + log << " Blade Chord = " << BladeChord << "\n"; + log << " Lift Curve Slope = " << LiftCurveSlope << "\n"; + log << " Blade Twist = " << BladeTwist << "\n"; + log << " Hinge Offset = " << HingeOffset << "\n"; + log << " Blade Flapping Moment = " << BladeFlappingMoment << "\n"; + log << " Blade Mass Moment = " << BladeMassMoment << "\n"; + log << " Polar Moment = " << PolarMoment << "\n"; + log << " Inflow Lag = " << InflowLag << "\n"; + log << " Tip Loss = " << TipLossB << "\n"; + log << " Lock Number = " << LockNumberByRho * 0.002356 << " (SL)\n"; + log << " Solidity = " << Solidity << "\n"; + log << " Max Brake Power = " << MaxBrakePower/hptoftlbssec << " HP\n"; + log << " Gear Loss = " << GearLoss/hptoftlbssec << " HP\n"; + log << " Gear Moment = " << GearMoment << "\n"; switch (ControlMap) { case eTailCtrl: ControlMapName = "Tail Rotor"; break; case eTandemCtrl: ControlMapName = "Tandem Rotor"; break; default: ControlMapName = "Main Rotor"; } - cout << " Control Mapping = " << ControlMapName << endl; + log << " Control Mapping = " << ControlMapName << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGRotor" << endl; - if (from == 1) cout << "Destroyed: FGRotor" << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGRotor\n"; + if (from == 1) log << "Destroyed: FGRotor\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } diff --git a/src/models/propulsion/FGThruster.cpp b/src/models/propulsion/FGThruster.cpp index 601f85bbd4..fd110b3b07 100644 --- a/src/models/propulsion/FGThruster.cpp +++ b/src/models/propulsion/FGThruster.cpp @@ -42,6 +42,7 @@ INCLUDES #include "input_output/FGPropertyManager.h" #include "FGThruster.h" #include "input_output/FGXMLElement.h" +#include "input_output/FGLog.h" using namespace std; @@ -72,7 +73,11 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx element = thruster_element->FindElement("location"); if (element) location = element->FindElementTripletConvertTo("IN"); - else cerr << fgred << " No thruster location found." << reset << endl; + else { + FGXMLLogging log(FDMExec->GetLogger(), thruster_element, LogLevel::ERROR); + log << LogFormat::RED << " No thruster location found." + << LogFormat::RESET << "\n"; + } SetLocation(location); @@ -196,8 +201,9 @@ void FGThruster::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - if (from == 0) cout << "Instantiated: FGThruster" << endl; - if (from == 1) cout << "Destroyed: FGThruster" << endl; + FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + if (from == 0) log << "Instantiated: FGThruster\n"; + if (from == 1) log << "Destroyed: FGThruster\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects }