diff --git a/src/FGFDMExec.cpp b/src/FGFDMExec.cpp index 3a3806f0f..eaaeed1bb 100644 --- a/src/FGFDMExec.cpp +++ b/src/FGFDMExec.cpp @@ -83,7 +83,6 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, std::shared_ptr fdmc { Frame = 0; disperse = 0; - Log = make_shared(); RootDir = ""; @@ -139,7 +138,7 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, std::shared_ptr fdmc try { Allocate(); } catch (const BaseException& e) { - LogException err(Log); + LogException err; err << endl << "Caught error: " << e.what() << endl; throw err; } @@ -174,7 +173,7 @@ FGFDMExec::~FGFDMExec() Unbind(); DeAllocate(); } catch (const string& msg ) { - FGLogging log(Log, LogLevel::FATAL); + FGLogging log(LogLevel::FATAL); log << "Caught error: " << msg << endl; } @@ -649,7 +648,7 @@ bool FGFDMExec::RunIC(void) if (debug_lvl > 0) { MassBalance->GetMassPropertiesReport(0); - FGLogging log(Log, LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << endl << LogFormat::BLUE << LogFormat::BOLD << "End of vehicle configuration loading." << endl << "-------------------------------------------------------------------------------" @@ -661,7 +660,7 @@ bool FGFDMExec::RunIC(void) try { Propulsion->InitRunning(n); } catch (const string& str) { - FGLogging log(Log, LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << str << endl; return false; } @@ -754,21 +753,21 @@ bool FGFDMExec::LoadPlanet(const SGPath& PlanetPath, bool useAircraftPath) // Make sure that the document is valid if (!document) { - LogException err(Log); + LogException err; err << "File: " << PlanetFileName << " could not be read." << endl; throw err; } if (document->GetName() != "planet") { - XMLLogException err(Log, document); - err << "File: " << PlanetFileName << " is not a planet file." << endl; - throw err; + XMLLogException err(document); + err << "File: " << PlanetFileName << " is not a planet file." << endl; + throw err; } bool result = LoadPlanet(document); if (!result) { - FGXMLLogging log(Log, document, LogLevel::ERROR); + FGXMLLogging log(document, LogLevel::ERROR); log << endl << "Planet element has problems in file " << PlanetFileName << endl; } @@ -802,7 +801,7 @@ bool FGFDMExec::LoadPlanet(Element* element) Atmosphere->InitModel(); result = Atmosphere->Load(atm_element); if (!result) { - FGLogging log(Log, LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << endl << "Incorrect definition of ." << endl; return result; } @@ -837,7 +836,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) modelName = model; // Set the class modelName attribute if( AircraftPath.isNull() || EnginePath.isNull() || SystemsPath.isNull()) { - FGLogging log(Log, LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Error: attempted to load aircraft with undefined " << "aircraft, engine, and system paths" << endl; return false; @@ -868,7 +867,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = ReadFileHeader(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft fileheader element has problems in file " << aircraftCfgFileName << endl; return result; } @@ -881,7 +880,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = LoadPlanet(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Planet element has problems in file " << aircraftCfgFileName << endl; return result; } @@ -892,12 +891,12 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = Models[eAircraft]->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft metrics element has problems in file " << aircraftCfgFileName << endl; return result; } } else { - FGLogging log(Log, LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << endl << "No metrics element was found in the aircraft config file." << endl; return false; } @@ -907,12 +906,12 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = Models[eMassBalance]->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft mass_balance element has problems in file " << aircraftCfgFileName << endl; return result; } } else { - FGLogging log(Log, LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << endl << "No mass_balance element was found in the aircraft config file." << endl; return false; } @@ -922,14 +921,14 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = Models[eGroundReactions]->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft ground_reactions element has problems in file " << aircraftCfgFileName << endl; return result; } } else { - FGLogging log(Log, LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << endl << "No ground_reactions element was found in the aircraft config file." << endl; return false; } @@ -939,7 +938,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = Models[eExternalReactions]->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft external_reactions element has problems in file " << aircraftCfgFileName << endl; return result; } @@ -950,7 +949,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = Models[eBuoyantForces]->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft buoyant_forces element has problems in file " << aircraftCfgFileName << endl; return result; } @@ -961,7 +960,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = Propulsion->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft propulsion element has problems in file " << aircraftCfgFileName << endl; return result; } @@ -974,7 +973,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) while (element) { result = Models[eSystems]->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft system element has problems in file " << aircraftCfgFileName << endl; return result; } @@ -986,7 +985,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = Models[eSystems]->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft autopilot element has problems in file " << aircraftCfgFileName << endl; return result; } @@ -997,7 +996,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = Models[eSystems]->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft flight_control element has problems in file " << aircraftCfgFileName << endl; return result; } @@ -1008,12 +1007,12 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = Models[eAerodynamics]->Load(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft aerodynamics element has problems in file " << aircraftCfgFileName << endl; return result; } } else { - FGLogging log(Log, LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << endl << "No expected aerodynamics element was found in the aircraft config file." << endl; } @@ -1041,7 +1040,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (element) { result = ReadChild(element); if (!result) { - FGXMLLogging log(Log, element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << endl << "Aircraft child element has problems in file " << aircraftCfgFileName << endl; return result; } @@ -1056,7 +1055,7 @@ bool FGFDMExec::LoadModel(const string& model, bool addModelToPath) if (IsChild) debug_lvl = saved_debug_lvl; } else { - FGLogging log(Log, LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << LogFormat::RED << " JSBSim failed to open the configuration file: " << aircraftCfgFileName << LogFormat::DEFAULT << endl; @@ -1124,7 +1123,7 @@ string FGFDMExec::QueryPropertyCatalog(const string& in, const string& end_of_li void FGFDMExec::PrintPropertyCatalog(void) { - FGLogging log(Log, LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << endl << " " << LogFormat::BLUE << highint << LogFormat::UNDERLINE_ON << "Property Catalog for " << modelName << LogFormat::RESET << endl << endl; @@ -1136,7 +1135,7 @@ void FGFDMExec::PrintPropertyCatalog(void) void FGFDMExec::PrintSimulationConfiguration(void) const { - FGLogging log(Log, LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << endl << "Simulation Configuration" << endl << "------------------------" << endl; log << MassBalance->GetName() << endl; log << GroundReactions->GetName() << endl; @@ -1148,7 +1147,7 @@ void FGFDMExec::PrintSimulationConfiguration(void) const bool FGFDMExec::ReadFileHeader(Element* el) { - FGLogging log(Log, LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (IsChild) { log << endl << LogFormat::BOLD << LogFormat::BLUE << "Reading child model: " @@ -1179,7 +1178,7 @@ bool FGFDMExec::ReadPrologue(Element* el) // el for ReadPrologue is the document Aircraft->SetAircraftName(AircraftName); if (debug_lvl & 1) { - FGLogging log(Log, LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << LogFormat::UNDERLINE_ON << "Reading Aircraft Configuration File" << LogFormat::UNDERLINE_OFF << ": " << LogFormat::BOLD << AircraftName << LogFormat::NORMAL << endl; @@ -1189,12 +1188,12 @@ bool FGFDMExec::ReadPrologue(Element* el) // el for ReadPrologue is the document Release = el->GetAttributeValue("release"); if (debug_lvl & 1) { - FGLogging log(Log, LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << " Version: " << LogFormat::BOLD << CFGVersion << LogFormat::NORMAL << endl; } if (CFGVersion != needed_cfg_version) { - FGLogging log(Log, LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << endl << LogFormat::RED << "YOU HAVE AN INCOMPATIBLE CFG FILE FOR THIS AIRCRAFT." " RESULTS WILL BE UNPREDICTABLE !!" << endl; log << "Current version needed is: " << needed_cfg_version << endl; @@ -1203,7 +1202,7 @@ bool FGFDMExec::ReadPrologue(Element* el) // el for ReadPrologue is the document } if (Release == "ALPHA" && (debug_lvl & 1)) { - FGLogging log(Log, LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << endl << endl << LogFormat::BOLD << "This aircraft model is an " << LogFormat::RED << Release << LogFormat::RESET << LogFormat::BOLD << " release!!!" << endl << endl << LogFormat::RESET @@ -1212,7 +1211,7 @@ bool FGFDMExec::ReadPrologue(Element* el) // el for ReadPrologue is the document << LogFormat::RED << LogFormat::BOLD << "Use this model for development purposes ONLY!!!" << LogFormat::NORMAL << LogFormat::RESET << endl << endl; } else if (Release == "BETA" && (debug_lvl & 1)) { - FGLogging log(Log, LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << endl << endl << LogFormat::BOLD << "This aircraft model is a " << LogFormat::RED << Release << LogFormat::RESET << LogFormat::BOLD << " release!!!" << endl << endl << LogFormat::RESET @@ -1220,12 +1219,12 @@ bool FGFDMExec::ReadPrologue(Element* el) // el for ReadPrologue is the document << LogFormat::BLUE << LogFormat::BOLD << "Use this model for development purposes ONLY!!!" << LogFormat::NORMAL << LogFormat::RESET << endl << endl; } else if (Release == "PRODUCTION" && (debug_lvl & 1)) { - FGLogging log(Log, LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << endl << endl << LogFormat::BOLD << "This aircraft model is a " << LogFormat::BLUE << Release << LogFormat::RESET << LogFormat::BOLD << " release." << endl << endl << LogFormat::RESET; } else if (debug_lvl & 1) { - FGLogging log(Log, LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << endl << endl << LogFormat::BOLD << "This aircraft model is an " << LogFormat::RED << Release << LogFormat::RESET << LogFormat::BOLD << " release!!!" << endl << endl << LogFormat::RESET @@ -1271,7 +1270,7 @@ bool FGFDMExec::ReadChild(Element* el) if (location) { child->Loc = location->FindElementTripletConvertTo("IN"); } else { - XMLLogException err(Log, el); + XMLLogException err(el); err << "No location was found for this child object!" << endl; throw err; } @@ -1280,7 +1279,7 @@ bool FGFDMExec::ReadChild(Element* el) if (orientation) { child->Orient = orientation->FindElementTripletConvertTo("RAD"); } else if (debug_lvl > 0) { - FGLogging log(Log, LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << endl << LogFormat::BOLD << " No orientation was found for this child object! Assuming 0,0,0." << LogFormat::RESET << endl; @@ -1385,7 +1384,7 @@ void FGFDMExec::Debug(int from) { if (debug_lvl <= 0) return; - FGLogging log(Log, LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (debug_lvl & 1 && IdFDM == 0) { // Standard console startup message output if (from == 0) { // Constructor diff --git a/src/FGFDMExec.h b/src/FGFDMExec.h index bf091dd17..062b578b2 100644 --- a/src/FGFDMExec.h +++ b/src/FGFDMExec.h @@ -509,9 +509,6 @@ class JSBSIM_API FGFDMExec : public FGJSBBase /// Sets the debug level. void SetDebugLevel(int level) {debug_lvl = level;} - void SetLogger(std::shared_ptr logger) {Log = logger;} - std::shared_ptr GetLogger(void) const {return Log;} - struct PropertyCatalogStructure { /// Name of the property. std::string base_string; @@ -632,10 +629,6 @@ class JSBSIM_API FGFDMExec : public FGJSBBase int SRand(void) const { return RandomSeed; } private: - // Declare Log first so that it's destroyed last: the logger may be used by - // some FGFDMExec members to log data during their destruction. - std::shared_ptr Log; - unsigned int Frame; unsigned int IdFDM; int disperse; diff --git a/src/initialization/FGInitialCondition.cpp b/src/initialization/FGInitialCondition.cpp index 6bb0e0835..ccb278940 100644 --- a/src/initialization/FGInitialCondition.cpp +++ b/src/initialization/FGInitialCondition.cpp @@ -289,7 +289,7 @@ void FGInitialCondition::SetVtrueFpsIC(double vtrue) void FGInitialCondition::SetClimbRateFpsIC(double hdot) { if (fabs(hdot) > vt) { - FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "The climb rate cannot be higher than the true speed.\n"; return; } @@ -364,7 +364,7 @@ void FGInitialCondition::calcThetaBeta(double alfa, const FGColumnVector3& _vt_N // following error being raised too often, we might need to reconsider this // position. if (DotProduct(v0, v0) < DotProduct(u, u)) { - FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Cannot modify angle 'alpha' from " << alpha << " to " << alfa << "\n"; return; } @@ -1020,13 +1020,13 @@ bool FGInitialCondition::Load(const SGPath& rstfile, bool useAircraftPath) // Make sure that the document is valid if (!document) { - LogException err(fdmex->GetLogger()); + LogException err; err << "File: " << init_file_name << " could not be read.\n"; throw err; } if (document->GetName() != "initialize") { - LogException err(fdmex->GetLogger()); + LogException err; err << "File: " << init_file_name << " is not a reset file.\n"; throw err; } @@ -1038,7 +1038,7 @@ bool FGInitialCondition::Load(const SGPath& rstfile, bool useAircraftPath) double version = document->GetAttributeValueAsNumber("version"); if (version >= 3.0) { - XMLLogException err(fdmex->GetLogger(), document); + XMLLogException err(document); err << "Only initialization file formats 1 and 2 are currently supported\n"; throw err; } else if (version >= 2.0) { @@ -1052,7 +1052,7 @@ bool FGInitialCondition::Load(const SGPath& rstfile, bool useAircraftPath) } // Check to see if any engines are specified to be initialized in a running state - Element* running_elements = document->FindElement("running"); + Element* running_elements = document->FindElement("running"); while (running_elements) { int engineNumber = int(running_elements->GetDataAsNumber()); enginesRunning |= engineNumber == -1 ? engineNumber : 1 << engineNumber; @@ -1075,7 +1075,7 @@ bool FGInitialCondition::LoadLatitude(Element* position_el) string unit_type = latitude_el->GetAttributeValue("unit"); if (unit_type.empty()) unit_type="RAD"; - FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << latitude_el->ReadFrom() << "The latitude value " << latitude_el->GetDataAsNumber() << " " << unit_type << " is outside the range ["; @@ -1254,7 +1254,7 @@ bool FGInitialCondition::Load_v2(Element* document) } else if (position_el->FindElement("altitudeMSL")) { SetAltitudeASLFtIC(position_el->FindElementValueAsNumberConvertTo("altitudeMSL", "FT")); } else { - FGXMLLogging log(fdmex->GetLogger(), position_el, LogLevel::ERROR); + FGXMLLogging log(position_el, LogLevel::ERROR); log << " No altitude or radius initial condition is given.\n"; result = false; } @@ -1266,12 +1266,12 @@ bool FGInitialCondition::Load_v2(Element* document) position = position_el->FindElementTripletConvertTo("FT"); } } else { - FGXMLLogging log(fdmex->GetLogger(), position_el, LogLevel::ERROR); + FGXMLLogging log(position_el, LogLevel::ERROR); log << " Neither ECI nor ECEF frame is specified for initial position.\n"; result = false; } } else { - FGXMLLogging log(fdmex->GetLogger(), document, LogLevel::ERROR); + FGXMLLogging log(document, LogLevel::ERROR); log << " Initial position not specified in this initialization file.\n"; result = false; } @@ -1347,7 +1347,7 @@ bool FGInitialCondition::Load_v2(Element* document) orientation = FGQuaternion(vOrient); } else { - FGXMLLogging log(fdmex->GetLogger(), orientation_el, LogLevel::ERROR); + FGXMLLogging log(orientation_el, LogLevel::ERROR); log << "\n" << LogFormat::RED << " Orientation frame type: \"" << frame << "\" is not supported!\n\n" << LogFormat::RESET; result = false; @@ -1386,7 +1386,7 @@ bool FGInitialCondition::Load_v2(Element* document) vUVW_NED = Tb2l * vInitVelocity; lastSpeedSet = setuvw; } else { - FGXMLLogging log(fdmex->GetLogger(), velocity_el, LogLevel::ERROR); + FGXMLLogging log(velocity_el, LogLevel::ERROR); log << "\n" << LogFormat::RED << " Velocity frame type: \"" << frame << "\" is not supported!\n\n" << LogFormat::RESET; result = false; @@ -1432,12 +1432,11 @@ bool FGInitialCondition::Load_v2(Element* document) vPQR_body = Tl2b * (vAttRate + vOmegaLocal); } else if (frame == "body") { vPQR_body = vAttRate; - } else if (!frame.empty()) { // misspelling of frame - FGXMLLogging log(fdmex->GetLogger(), attrate_el, LogLevel::ERROR); + } else if (!frame.empty()) { // misspelling of frame + FGXMLLogging log(attrate_el, LogLevel::ERROR); log << endl << LogFormat::RED << " Attitude rate frame type: \"" << frame << "\" is not supported!\n\n" << LogFormat::RESET; result = false; - } else if (frame.empty()) { vPQR_body.InitMatrix(); } @@ -1623,7 +1622,7 @@ void FGInitialCondition::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGInitialCondition\n"; if (from == 1) log << "Destroyed: FGInitialCondition\n"; } diff --git a/src/initialization/FGLinearization.cpp b/src/initialization/FGLinearization.cpp index 91334d31d..db38d5e2c 100644 --- a/src/initialization/FGLinearization.cpp +++ b/src/initialization/FGLinearization.cpp @@ -46,7 +46,7 @@ FGLinearization::FGLinearization(FGFDMExec * fdm) if (numEngines>2) ss.x.add(new FGStateSpace::Rpm2); if (numEngines>3) ss.x.add(new FGStateSpace::Rpm3); if (numEngines>4) { - FGLogging log(fdm->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "More than 4 engines not currently handled\n"; } } diff --git a/src/initialization/FGSimplexTrim.cpp b/src/initialization/FGSimplexTrim.cpp index 68f1855f6..4747bc827 100644 --- a/src/initialization/FGSimplexTrim.cpp +++ b/src/initialization/FGSimplexTrim.cpp @@ -32,7 +32,7 @@ FGSimplexTrim::FGSimplexTrim(FGFDMExec * fdm, TrimMode mode) FGTrimmer::Constraints constraints; if (fdm->GetDebugLevel() > 0) { - FGLogging log(fdm->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n-----Performing Simplex Based Trim --------------\n"; } @@ -107,7 +107,7 @@ FGSimplexTrim::FGSimplexTrim(FGFDMExec * fdm, TrimMode mode) // output if (fdm->GetDebugLevel() > 0) { - FGLogging log(fdm->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); trimmer->printSolution(solver->getSolution()); log << "\nfinal cost: " << std::scientific << std::setw(10) << trimmer->eval(solver->getSolution()) << "\n"; log << "\ntrim computation time: " << (time_trimDone - time_start)/double(CLOCKS_PER_SEC) << "s \n\n"; diff --git a/src/initialization/FGSimplexTrim.h b/src/initialization/FGSimplexTrim.h index 1bf27c3e2..7e91580ca 100644 --- a/src/initialization/FGSimplexTrim.h +++ b/src/initialization/FGSimplexTrim.h @@ -67,7 +67,7 @@ class FGSimplexTrim void eval(const std::vector &v) { _outputFile << _trimmer->eval(v) << std::endl; - // FGLogging log(_trimmer->getFdm()->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << "v: "; //for (int i=0;iGetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "Instantiated: FGTrim\n"; } } @@ -89,7 +89,7 @@ FGTrim::FGTrim(FGFDMExec *FDMExec,TrimMode tt) FGTrim::~FGTrim(void) { if (debug_lvl & 2) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "Destroyed: FGTrim\n"; } } @@ -98,7 +98,7 @@ FGTrim::~FGTrim(void) { void FGTrim::TrimStats() { int run_sum=0; - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "\n Trim Statistics:\n"; log << " Total Iterations: " << total_its << "\n"; if( total_its > 0) { @@ -119,7 +119,7 @@ void FGTrim::TrimStats() { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void FGTrim::Report(void) { - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << " Trim Results:\n"; for(unsigned int current_axis=0; current_axisGetLogger(), LogLevel::INFO); - //log << "TrimAxes.size(): " << TrimAxes.size() << "\n"; + //FGLogging log(LogLevel::INFO); + //log << "TrimAxes.size(): " << TrimAxes.size() << "\n"; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -229,7 +229,7 @@ bool FGTrim::DoTrim(void) { //clear the sub iterations counts & zero out the controls for(unsigned int current_axis=0;current_axisGetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << current_axis << " " << TrimAxes[current_axis]->GetStateName() //<< " " << TrimAxes[current_axis]->GetControlName()<< "\n"; xlo=TrimAxes[current_axis].GetControlMin(); @@ -243,7 +243,7 @@ bool FGTrim::DoTrim(void) { } if(mode == tPullup ) { - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "Setting pitch rate and nlf...\n"; setupPullup(); log << "pitch rate done ...\n"; @@ -282,7 +282,7 @@ bool FGTrim::DoTrim(void) { } if((axis_count == TrimAxes.size()-1) && (TrimAxes.size() > 1)) { - //FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << TrimAxes.size()-1 << " out of " << TrimAxes.size() << "!" << "\n"; //At this point we can check the input limits of the failed axis //and declare the trim failed if there is no sign change. If there @@ -298,7 +298,7 @@ bool FGTrim::DoTrim(void) { if( (gamma_fallback) && (TrimAxes[current_axis].GetStateType() == tUdot) && (TrimAxes[current_axis].GetControlType() == tThrottle)) { - FGLogging log(fdmex->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << " Can't trim udot with throttle, trying flight" << " path angle. (" << N << ")\n"; if(TrimAxes[current_axis].GetState() > 0) @@ -308,7 +308,7 @@ bool FGTrim::DoTrim(void) { TrimAxes[current_axis].Run(); TrimAxes[current_axis]=FGTrimAxis(fdmex,&fgic,tUdot,tGamma); } else { - FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << " Sorry, " << TrimAxes[current_axis].GetStateName() << " doesn't appear to be trimmable\n"; //total_its=k; @@ -326,7 +326,7 @@ bool FGTrim::DoTrim(void) { if((!trim_failed) && (axis_count >= TrimAxes.size())) { total_its=N; if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Trim successful\n"; } } else { // The trim has failed @@ -349,7 +349,7 @@ bool FGTrim::DoTrim(void) { trimOnGround(); if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Trim failed\n"; } } @@ -533,7 +533,7 @@ FGTrim::RotationParameters FGTrim::calcRotation(vector& contacts, // the ground is (0, DistPlane, alpha) in the basis (u, v, t) double mag = sqrRadius - DistPlane * DistPlane; if (mag < 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "FGTrim::calcRotation DistPlane^2 larger than sqrRadius\n"; } double alpha = sqrt(max(mag, 0.0)); @@ -586,7 +586,7 @@ bool FGTrim::solve(FGTrimAxis& axis) { axis.Run(); f2=axis.GetState(); if(Debug > 1) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "FGTrim::solve Nsub,x1,x2,x3: " << Nsub << ", " << x1 << ", " << x2 << ", " << x3 << "\n"; log << " " << f1 << ", " << f2 << ", " << f3 << "\n"; @@ -595,18 +595,18 @@ bool FGTrim::solve(FGTrimAxis& axis) { x3=x2; f3=f2; f1=relax*f1; - //FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << "Solution is between x1 and x2" << "\n"; } else if(f2*f3 <= 0.0) { x1=x2; f1=f2; f3=relax*f3; - //FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << "Solution is between x2 and x3" << "\n"; } - //FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << i << "\n"; @@ -690,7 +690,7 @@ bool FGTrim::findInterval(FGTrimAxis& axis) { lastalo=alo;lastahi=ahi; if( !found && xlo==xmin && xhi==xmax ) continue; if(Debug > 1) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "FGTrim::findInterval: Nsub=" << Nsub << " Lo= " << xlo << " Hi= " << xhi << " alo*ahi: " << alo*ahi << "\n"; } @@ -728,7 +728,7 @@ bool FGTrim::checkLimits(FGTrimAxis& axis) axis.Run(); ahi=axis.GetState(); if(Debug > 1) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "checkLimits() xlo,xhi,alo,ahi: " << xlo << ", " << xhi << ", " << alo << ", " << ahi << "\n"; } @@ -758,7 +758,7 @@ void FGTrim::setupPullup() { double g,q,cgamma; g=fdmex->GetInertial()->GetGravity().Magnitude(); cgamma=cos(fgic.GetFlightPathAngleRadIC()); - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "setPitchRateInPullup(): " << g << ", " << cgamma << ", " << fgic.GetVtrueFpsIC() << "\n"; q=g*(targetNlf-cgamma)/fgic.GetVtrueFpsIC(); @@ -777,7 +777,7 @@ void FGTrim::setupTurn(void){ targetNlf = 1 / cos(phi); g = fdmex->GetInertial()->GetGravity().Magnitude(); psidot = g*tan(phi) / fgic.GetUBodyFpsIC(); - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << targetNlf << ", " << psidot << "\n"; } @@ -833,7 +833,7 @@ void FGTrim::SetMode(TrimMode tt) { switch(tt) { case tFull: if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Full Trim\n"; } TrimAxes.push_back(FGTrimAxis(fdmex,&fgic,tWdot,tAlpha)); @@ -846,7 +846,7 @@ void FGTrim::SetMode(TrimMode tt) { break; case tLongitudinal: if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Longitudinal Trim\n"; } TrimAxes.push_back(FGTrimAxis(fdmex,&fgic,tWdot,tAlpha )); @@ -855,7 +855,7 @@ void FGTrim::SetMode(TrimMode tt) { break; case tGround: if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Ground Trim\n"; } TrimAxes.push_back(FGTrimAxis(fdmex,&fgic,tWdot,tAltAGL )); @@ -883,7 +883,7 @@ void FGTrim::SetMode(TrimMode tt) { case tNone: break; } - //FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << "TrimAxes.size(): " << TrimAxes.size() << "\n"; sub_iterations.resize(TrimAxes.size()); successful.resize(TrimAxes.size()); diff --git a/src/initialization/FGTrimAnalysis.cpp b/src/initialization/FGTrimAnalysis.cpp index 54b6c3133..6e69ef86c 100644 --- a/src/initialization/FGTrimAnalysis.cpp +++ b/src/initialization/FGTrimAnalysis.cpp @@ -103,13 +103,13 @@ IDENT(IdHdr,ID_FGTRIMANALYSIS); * Note that in the call masked by this methods, the void pointer * should be cast to a pointer of the class type. */ - //friend void find_CostFunctionFull(long vars, Vector &v, double & f, + //friend void find_CostFunctionFull(long vars, Vector &v, double & f, void find_CostFunctionFull(long vars, Vector &v, double & f, bool & success, void* t_ptr) - { - (*(Objective*)t_ptr).CostFunctionFull(vars, v, f); - success = true; - } + { + (*(Objective*)t_ptr).CostFunctionFull(vars, v, f); + success = true; + } /** Wrapping function for the effective Wings Level Trim cost function, to be called by optimization method @param vars number ofcontrol varables @param v reference to a vector containing controls variables @@ -122,13 +122,13 @@ IDENT(IdHdr,ID_FGTRIMANALYSIS); * Note that in the call masked by this methods, the void pointer * should be cast to a pointer of the class type. */ - //friend void find_CostFunctionFullWingsLevel(long vars, Vector &v, double & f, + //friend void find_CostFunctionFullWingsLevel(long vars, Vector &v, double & f, void find_CostFunctionFullWingsLevel(long vars, Vector &v, double & f, bool & success, void* t_ptr) - { - (*(Objective*)t_ptr).CostFunctionFullWingsLevel(vars, v, f); - success = true; - } + { + (*(Objective*)t_ptr).CostFunctionFullWingsLevel(vars, v, f); + success = true; + } /** Wrapping function for the effective Longitudinal Trim cost function, to be called by optimization method @param vars number ofcontrol varables @param v reference to a vector containing controls variables @@ -141,13 +141,13 @@ IDENT(IdHdr,ID_FGTRIMANALYSIS); * Note that in the call masked by this methods, the void pointer * should be cast to a pointer of the class type. */ - //friend void find_CostFunctionLongitudinal(long vars, Vector &v, double & f, + //friend void find_CostFunctionLongitudinal(long vars, Vector &v, double & f, void find_CostFunctionLongitudinal(long vars, Vector &v, double & f, bool & success, void* t_ptr) - { - (*(Objective*)t_ptr).CostFunctionLongitudinal(vars, v, f); - success = true; - } + { + (*(Objective*)t_ptr).CostFunctionLongitudinal(vars, v, f); + success = true; + } /** Wrapping function for the effective Steady Turn Trim cost function, to be called by optimization method @param vars number ofcontrol varables @param v reference to a vector containing controls variables @@ -160,13 +160,13 @@ IDENT(IdHdr,ID_FGTRIMANALYSIS); * Note that in the call masked by this methods, the void pointer * should be cast to a pointer of the class type. */ - //friend void find_CostFunctionFullCoordinatedTurn(long vars, Vector &v, double & f, + //friend void find_CostFunctionFullCoordinatedTurn(long vars, Vector &v, double & f, void find_CostFunctionFullCoordinatedTurn(long vars, Vector &v, double & f, bool & success, void* t_ptr) - { - (*(Objective*)t_ptr).CostFunctionFullCoordinatedTurn(vars, v, f); - success = true; - } + { + (*(Objective*)t_ptr).CostFunctionFullCoordinatedTurn(vars, v, f); + success = true; + } /** Wrapping function for the effective Steady Turn Trim cost function, to be called by optimization method @param vars number ofcontrol varables @param v reference to a vector containing controls variables @@ -179,13 +179,13 @@ IDENT(IdHdr,ID_FGTRIMANALYSIS); * Note that in the call masked by this methods, the void pointer * should be cast to a pointer of the class type. */ - //fryyiend void find_CostFunctionFullTurn(long vars, Vector &v, double & f, + //fryyiend void find_CostFunctionFullTurn(long vars, Vector &v, double & f, void find_CostFunctionFullTurn(long vars, Vector &v, double & f, bool & success, void* t_ptr) - { - (*(Objective*)t_ptr).CostFunctionFullTurn(vars, v, f); - success = true; - } + { + (*(Objective*)t_ptr).CostFunctionFullTurn(vars, v, f); + success = true; + } /** Wrapping function for the effective Pullup Trim cost function, to be called by optimization method @param vars number ofcontrol varables @param v reference to a vector containing controls variables @@ -198,13 +198,13 @@ IDENT(IdHdr,ID_FGTRIMANALYSIS); * Note that in the call masked by this methods, the void pointer * should be cast to a pointer of the class type. */ - //friend void find_CostFunctionPullUp(long vars, Vector &v, double & f, + //friend void find_CostFunctionPullUp(long vars, Vector &v, double & f, void find_CostFunctionPullUp(long vars, Vector &v, double & f, bool & success, void* t_ptr) - { - (*(Objective*)t_ptr).CostFunctionPullUp(vars, v, f); - success = true; - } + { + (*(Objective*)t_ptr).CostFunctionPullUp(vars, v, f); + success = true; + } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //public: @@ -221,12 +221,12 @@ Objective::Objective(FGFDMExec* fdmex, FGTrimAnalysis* ta, double x) : _x(x), Tr void Objective::CostFunctionFull(long vars, Vector &v, double & f) { if (vars != 7) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: (Cost function for taFull mode) Dimension must be 7 !!\n"; throw err; } if (TrimAnalysis->GetMode()!=taFull){ - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: must be taFull mode !!\n"; throw err; } @@ -238,12 +238,12 @@ void Objective::CostFunctionFull(long vars, Vector &v, double & f) void Objective::CostFunctionFullWingsLevel(long vars, Vector &v, double & f) { if (vars != 6) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: (Cost function for taFullWingsLevel mode) Dimension must be 6 !!\n"; throw err; } if (TrimAnalysis->GetMode()!=taFullWingsLevel){ - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: must be taFull mode !!\n"; throw err; } @@ -255,12 +255,12 @@ void Objective::CostFunctionFullWingsLevel(long vars, Vector &v, double void Objective::CostFunctionLongitudinal(long vars, Vector &v, double & f) { if (vars != 3) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: (Cost function for taLongitudinal mode) Dimension must be 3 !!\n"; throw err; } if (TrimAnalysis->GetMode()!=taLongitudinal){ - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: trim mode must be taLongitudinal mode !!\n"; throw err; } @@ -272,12 +272,12 @@ void Objective::CostFunctionLongitudinal(long vars, Vector &v, double & void Objective::CostFunctionFullCoordinatedTurn(long vars, Vector &v, double & f) { if (vars != 5) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: (Cost function for taTurn mode) Dimension must be 5 !!\n"; throw err; } if (TrimAnalysis->GetMode()!=taTurn){ - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: trim mode must be taTurn mode !!\n"; throw err; } @@ -289,12 +289,12 @@ void Objective::CostFunctionFullCoordinatedTurn(long vars, Vector &v, do void Objective::CostFunctionFullTurn(long vars, Vector &v, double & f) { if (vars != 6) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: (Cost function for taTurn mode) Dimension must be 6 !!\n"; throw err; } if (TrimAnalysis->GetMode()!=taTurnFull){ - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: trim mode must be taTurnFull ("<< (int)taTurnFull << ") mode !!\n"; throw err; } @@ -306,12 +306,12 @@ void Objective::CostFunctionFullTurn(long vars, Vector &v, double & f) void Objective::CostFunctionPullUp(long vars, Vector &v, double & f) { if (vars != 5) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: (Cost function for taPullup mode) Dimension must be 5 !!\n"; throw err; } if (TrimAnalysis->GetMode()!=taPullup){ - LogException err(FDMExec->GetLogger()); + LogException err; err << "\nError: trim mode must be taPullup mode !!\n"; throw err; } @@ -480,11 +480,11 @@ bool FGTrimAnalysis::Load(string fname, bool useStoredPath) document = this->LoadXMLDocument(trimDef); trimCfg = document->FindElement("trim_config"); - if (!trimCfg) { - FGLogging log(fdmex->GetLogger(), document, LogLevel::ERROR); - log << "File: " << trimDef << " does not contain a trim configuration tag\n"; - return false; - } + if (!trimCfg) { + FGLogging log(document, LogLevel::ERROR); + log << "File: " << trimDef << " does not contain a trim configuration tag\n"; + return false; + } name = trimCfg->GetAttributeValue("name"); trim_id = name; @@ -492,10 +492,10 @@ bool FGTrimAnalysis::Load(string fname, bool useStoredPath) // First, find "search" element that specifies the type of cost function minimum search search_element = trimCfg->FindElement("search"); - if (!search_element) { - FGXMLLogging log(fdmex->GetLogger(), trimCfg, LogLevel::ERROR); - log << "Using the Nelder-Mead search algorithm (default).\n"; - } else { + if (!search_element) { + FGXMLLogging log(trimCfg, LogLevel::ERROR); + log << "Using the Nelder-Mead search algorithm (default).\n"; + } else { type = search_element->GetAttributeValue("type"); if (type.size() > 0) search_type = type; // if search type is not set, default is already Nelder-Mead if (search_type == "Nelder-Mead") { @@ -566,15 +566,15 @@ bool FGTrimAnalysis::Load(string fname, bool useStoredPath) output_element = trimCfg->FindElement("output_file"); if (output_element) { rf_name = output_element->GetAttributeValue("name"); - if (rf_name.empty()) { - FGXMLLogging log(fdmex->GetLogger(), output_element, LogLevel::ERROR); - log << "name must be specified in output_file \"name\" attribute.\n"; - } else { - if ( !SetResultsFile(rf_name) ) { - FGXMLLogging log(fdmex->GetLogger(), output_element, LogLevel::ERROR); - log << "Unable to use output file "<< rf_name << "\n"; - } - } + if (rf_name.empty()) { + FGXMLLogging log(output_element, LogLevel::ERROR); + log << "name must be specified in output_file \"name\" attribute.\n"; + } else { + if ( !SetResultsFile(rf_name) ) { + FGXMLLogging log(output_element, LogLevel::ERROR); + log << "Unable to use output file "<< rf_name << "\n"; + } + } } return true; } @@ -619,7 +619,7 @@ bool FGTrimAnalysis::InitializeTrimControl(double default_value, Element* el, void FGTrimAnalysis::TrimStats() { int run_sum=0; - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "\n Trim Statistics:\n"; log << " Total Iterations: " << total_its << "\n"; } @@ -627,8 +627,8 @@ void FGTrimAnalysis::TrimStats() { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void FGTrimAnalysis::Report(void) { - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); - log << "---------------------------------------------------------------------\n"; + FGLogging log(LogLevel::INFO); + log << "---------------------------------------------------------------------\n"; log << "Trim report:\n"; log << "\tTrim algorithm terminated with the following values:\n"; @@ -758,7 +758,7 @@ bool FGTrimAnalysis::EditState( TaControl new_control, double new_initvalue, dou //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void FGTrimAnalysis::setupPullup() { - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); double g,q,cgamma; g=fdmex->GetInertial()->gravity(); cgamma=cos(fgic->GetFlightPathAngleRadIC()); @@ -1017,16 +1017,16 @@ void FGTrimAnalysis::setDebug(void) { void FGTrimAnalysis::SetMode(TrimAnalysisMode tt) { ClearControls(); - { - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); - log << "---------------------------------------------------------------------\n"; - log << "Trim analysis performed: "; - } + { + FGLogging log(LogLevel::INFO); + log << "---------------------------------------------------------------------\n"; + log << "Trim analysis performed: "; + } mode=tt; switch(tt) { case taLongitudinal: if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Longitudinal Trim\n"; } vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle )); @@ -1035,7 +1035,7 @@ void FGTrimAnalysis::SetMode(TrimAnalysisMode tt) { break; case taFull: if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Full Trim\n"; } vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle )); @@ -1048,7 +1048,7 @@ void FGTrimAnalysis::SetMode(TrimAnalysisMode tt) { break; case taFullWingsLevel: if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Full Trim, Wings-Level\n"; } vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle )); @@ -1062,7 +1062,7 @@ void FGTrimAnalysis::SetMode(TrimAnalysisMode tt) { // ToDo: set target NLF here !!! // ToDo: assign psiDot here !! if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Full Trim, Coordinated turn\n"; } vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle )); @@ -1075,7 +1075,7 @@ void FGTrimAnalysis::SetMode(TrimAnalysisMode tt) { break; case taTurnFull: if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Non-coordinated Turn Trim\n"; } vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle )); @@ -1091,7 +1091,7 @@ void FGTrimAnalysis::SetMode(TrimAnalysisMode tt) { // ToDo: set target NLF here !!! // ToDo: assign qDot here !! if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Full Trim, Pullup\n"; } vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taThrottle )); @@ -1104,7 +1104,7 @@ void FGTrimAnalysis::SetMode(TrimAnalysisMode tt) { break; case taGround: if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Ground Trim\n"; } vTrimAnalysisControls.push_back(new FGTrimAnalysisControl(fdmex,fgic,taAltAGL )); @@ -1128,11 +1128,11 @@ bool FGTrimAnalysis::SetResultsFile(string name) rf_name = name; rf.open(rf_name.c_str(), ios::out); - if ( !rf.is_open() ) { - FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); - log << "Unable to open " << rf_name << "\n"; - return false; - } + if ( !rf.is_open() ) { + FGLogging log(LogLevel::ERROR); + log << "Unable to open " << rf_name << "\n"; + return false; + } //rf << "# ... complete this\n"; //rf << "# iteration, CostFunc, size, dT, dE, dA, dR, Psi (rad), Theta (rad), Phi (rad)\n"; return true; @@ -1315,7 +1315,7 @@ bool FGTrimAnalysis::DoTrim(void) { // retrieve initial conditions fdmex->RunIC(); - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "\nNumerical trim algorithm: constrained optimization of a cost function\n"; Objective* obj_ptr = new Objective(this->fdmex, this, 999.0); @@ -1732,12 +1732,12 @@ bool FGTrimAnalysis::DoTrim(void) { if( !trim_failed ) { if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Trim successful. (Cost function value: " << cost_function_value << ")\n"; } } else { if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Trim failed\n"; } } @@ -3056,7 +3056,7 @@ void Objective::calculateDottedStates(double delta_cmd_T, double delta_cmd_E, do double rd = FDMExec->GetPropagate()->GetRadius(); // radius if (rd == 0.0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "radius = 0 !\n"; rd = 1e-16; } // radius check diff --git a/src/initialization/FGTrimAnalysisControl.cpp b/src/initialization/FGTrimAnalysisControl.cpp index 65990d800..c42f3624e 100644 --- a/src/initialization/FGTrimAnalysisControl.cpp +++ b/src/initialization/FGTrimAnalysisControl.cpp @@ -184,7 +184,7 @@ FGTrimAnalysisControl::FGTrimAnalysisControl(FGFDMExec* fdex, FGInitialCondition } // if (debug_lvl > 0) { -// FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); +// FGLogging log(LogLevel::DEBUG); // log << "FGTrimAnalysisControl created: "<< control_name << "\n"; // } @@ -309,7 +309,7 @@ void FGTrimAnalysisControl::SetThetaOnGround(double ff) { ref=center; } - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "SetThetaOnGround ref gear: " << ref << "\n"; if(ref >= 0) { double sp = fdmex->GetPropagate()->GetSinEuler(ePhi); @@ -380,7 +380,7 @@ bool FGTrimAnalysisControl::initTheta(void) { zAft=fdmex->GetGroundReactions()->GetGearUnit(iAft)->GetLocalGear(3); zForward=fdmex->GetGroundReactions()->GetGearUnit(iForward)->GetLocalGear(3); zDiff = zForward - zAft; - //FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << "\n" << theta << " " << zDiff << "\n"; //log << "0: " << fdmex->GetGroundReactions()->GetGearUnit(0)->GetLocalGear() << "\n"; //log << "1: " << fdmex->GetGroundReactions()->GetGearUnit(1)->GetLocalGear() << "\n"; @@ -388,10 +388,10 @@ bool FGTrimAnalysisControl::initTheta(void) { level=true; i++; } - //FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << i << "\n"; if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Initial Theta: " << fdmex->GetPropagate()->GetEuler(eTht)*radtodeg << "\n"; log << " Used gear unit " << iAft << " as aft and " << iForward << " as forward\n"; } @@ -447,7 +447,7 @@ void FGTrimAnalysisControl::setThrottlesPct(void) { for(unsigned i=0;iGetPropulsion()->GetNumEngines();i++) { tMin=fdmex->GetPropulsion()->GetEngine(i)->GetThrottleMin(); tMax=fdmex->GetPropulsion()->GetEngine(i)->GetThrottleMax(); - //FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << "setThrottlespct: " << i << ", " << control_min << ", " << control_max << ", " << control_value; fdmex->GetFCS()->SetThrottleCmd(i,tMin+control_value*(tMax-tMin)); //log << "setThrottlespct: " << fdmex->GetFCS()->GetThrottleCmd(i) << "\n"; @@ -491,7 +491,7 @@ void FGTrimAnalysisControl::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGTrimAnalysisControl\n"; if (from == 1) log << "Destroyed: FGTrimAnalysisControl\n"; } diff --git a/src/initialization/FGTrimAxis.cpp b/src/initialization/FGTrimAxis.cpp index 878101ab6..c498e7ca7 100644 --- a/src/initialization/FGTrimAxis.cpp +++ b/src/initialization/FGTrimAxis.cpp @@ -250,7 +250,7 @@ void FGTrimAxis::Run(void) { double last_state_value; int i; setControl(); - //FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + //FGLogging log(LogLevel::INFO); //log << "FGTrimAxis::Run: " << control_value << "\n"; i=0; bool stable=false; @@ -293,7 +293,7 @@ void FGTrimAxis::setThrottlesPct(void) { /*****************************************************************************/ void FGTrimAxis::AxisReport(void) { - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << " " << left << setw(20) << GetControlName() << ": "; log << setw(6) << setprecision(2) << GetControl()*control_convert << ' '; log << setw(5) << GetStateName() << ": "; @@ -344,7 +344,7 @@ void FGTrimAxis::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGTrimAxis\n"; if (from == 1) log << "Destroyed: FGTrimAxis\n"; } diff --git a/src/initialization/FGTrimmer.cpp b/src/initialization/FGTrimmer.cpp index baf8b3c39..9bc499485 100644 --- a/src/initialization/FGTrimmer.cpp +++ b/src/initialization/FGTrimmer.cpp @@ -165,14 +165,14 @@ std::vector FGTrimmer::constrain(const std::vector & dv) double dcost = fabs(costNew - cost); if (dcost < std::numeric_limits::epsilon()) { if(m_fdm->GetDebugLevel() > 1) { - FGLogging log(m_fdm->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "cost convergd, i: " << i << std::endl; } break; } if (i > 1000) { if(m_fdm->GetDebugLevel() > 1) { - FGLogging log(m_fdm->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "cost failed to converge, dcost: " << std::scientific << dcost << std::endl; @@ -215,7 +215,7 @@ void FGTrimmer::printSolution(const std::vector & v) eval(v); // state - FGLogging log(m_fdm->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << std::setw(10) // aircraft state @@ -298,7 +298,7 @@ void FGTrimmer::printSolution(const std::vector & v) void FGTrimmer::printState() { // state - FGLogging log(m_fdm->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << std::setw(10) // interval method comparison @@ -359,7 +359,7 @@ double FGTrimmer::compute_cost() double dr = m_fdm->GetAccelerations()->GetPQRdot(3); if(m_fdm->GetDebugLevel() > 1) { - FGLogging log(m_fdm->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "dvt: " << dvt << "\tdalpha: " << dalpha diff --git a/src/input_output/FGInputSocket.cpp b/src/input_output/FGInputSocket.cpp index 43c4a62d4..b052480bc 100644 --- a/src/input_output/FGInputSocket.cpp +++ b/src/input_output/FGInputSocket.cpp @@ -76,7 +76,7 @@ bool FGInputSocket::Load(Element* el) SockPort = atoi(el->GetAttributeValue("port").c_str()); if (SockPort == 0) { - FGXMLLogging log(FDMExec->GetLogger(), el, LogLevel::ERROR); + FGXMLLogging log(el, LogLevel::ERROR); log << "No port assigned in input element\n"; return false; } diff --git a/src/input_output/FGInputType.cpp b/src/input_output/FGInputType.cpp index bade6c1c2..5f9c1d80d 100644 --- a/src/input_output/FGInputType.cpp +++ b/src/input_output/FGInputType.cpp @@ -142,7 +142,7 @@ void FGInputType::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGInputType\n"; if (from == 1) log << "Destroyed: FGInputType\n"; } diff --git a/src/input_output/FGLog.cpp b/src/input_output/FGLog.cpp index 7d509c6f3..ed7244137 100644 --- a/src/input_output/FGLog.cpp +++ b/src/input_output/FGLog.cpp @@ -46,6 +46,12 @@ INCLUDES namespace JSBSim { +thread_local FGLogger_ptr GlobalLogger = std::make_shared(); + +void SetLogger(FGLogger_ptr logger) { GlobalLogger = logger; } +FGLogger_ptr GetLogger(void) { return GlobalLogger; } + + /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CLASS IMPLEMENTATION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/ @@ -53,9 +59,7 @@ CLASS IMPLEMENTATION class BufferLogger : public FGLogger { public: - BufferLogger(std::shared_ptr logger) : logger(logger) { - logMessageBuffer[0] = '\0'; - } + BufferLogger() { logMessageBuffer[0] = '\0'; } void FileLocation(const std::string& filename, int line) override { this->filename = filename; this->line = line; @@ -75,7 +79,6 @@ class BufferLogger : public FGLogger char logMessageBuffer[1024]; size_t bufferUsed = 0; std::vector tokens; - const std::shared_ptr logger; std::string filename; int line = -1; }; @@ -114,18 +117,26 @@ BufferLogger::~BufferLogger() { if (tokens.empty()) return; - logger->SetLevel(log_level); + GlobalLogger->SetLevel(log_level); - if (line > 0) logger->FileLocation(filename, line); + if (line > 0) GlobalLogger->FileLocation(filename, line); for (const auto& token : tokens) { if (token.messageItem.empty()) { - logger->Format(token.format); + GlobalLogger->Format(token.format); continue; } - logger->Message(std::string(token.messageItem)); + GlobalLogger->Message(std::string(token.messageItem)); } - logger->Flush(); + GlobalLogger->Flush(); +} + +//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +FGLogging::FGLogging(LogLevel level) + : logger(GlobalLogger) +{ + logger->SetLevel(level); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -144,7 +155,8 @@ void FGLogging::Flush(void) //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGLogging& FGLogging::operator<<(LogFormat format) { +FGLogging& FGLogging::operator<<(LogFormat format) +{ std::string message = buffer.str(); if (!message.empty()) { @@ -158,8 +170,8 @@ FGLogging& FGLogging::operator<<(LogFormat format) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -FGXMLLogging::FGXMLLogging(std::shared_ptr logger, Element* el, LogLevel level) - : FGLogging(logger, level) +FGXMLLogging::FGXMLLogging(Element* el, LogLevel level) + : FGLogging(level) { logger->FileLocation(el->GetFileName(), el->GetLineNumber()); } @@ -219,13 +231,16 @@ void FGLogConsole::Format(LogFormat format) { //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -LogException::LogException(std::shared_ptr logger) -: BaseException(""), FGLogging(std::make_shared(logger), LogLevel::FATAL) {} +LogException::LogException() +: BaseException(""), FGLogging(std::make_shared()) +{ + logger->SetLevel(LogLevel::FATAL); +} //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LogException::LogException(LogException& other) -: BaseException(""), FGLogging(other.logger, LogLevel::FATAL) +: BaseException(""), FGLogging(other.logger) { other.Flush(); // Make the data buffered in `other` accessible to all copies. } @@ -245,10 +260,10 @@ const char* LogException::what() const noexcept //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -XMLLogException::XMLLogException(std::shared_ptr logger, Element* el) - : LogException(logger) +XMLLogException::XMLLogException(Element* el) + : LogException() { - this->logger->FileLocation(el->GetFileName(), el->GetLineNumber()); + logger->FileLocation(el->GetFileName(), el->GetLineNumber()); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/input_output/FGLog.h b/src/input_output/FGLog.h index 6d6d8f63a..795be0544 100644 --- a/src/input_output/FGLog.h +++ b/src/input_output/FGLog.h @@ -106,12 +106,15 @@ class JSBSIM_API FGLogger LogLevel log_level = LogLevel::BULK; }; +using FGLogger_ptr = std::shared_ptr; + +JSBSIM_API void SetLogger(FGLogger_ptr logger); +JSBSIM_API FGLogger_ptr GetLogger(void); + class JSBSIM_API FGLogging { public: - FGLogging(std::shared_ptr logger, LogLevel level) - : logger(logger) - { logger->SetLevel(level); } + FGLogging(LogLevel level); virtual ~FGLogging() { Flush(); } FGLogging& operator<<(const char* message) { buffer << message ; return *this; } @@ -134,14 +137,16 @@ class JSBSIM_API FGLogging FGLogging& operator<<(LogFormat format); void Flush(void); protected: - std::shared_ptr logger; + FGLogging(FGLogger_ptr l) : logger(l) {} + + FGLogger_ptr logger; std::ostringstream buffer; }; class JSBSIM_API FGXMLLogging : public FGLogging { public: - FGXMLLogging(std::shared_ptr logger, Element* el, LogLevel level); + FGXMLLogging(Element* el, LogLevel level); }; class JSBSIM_API FGLogConsole : public FGLogger @@ -152,6 +157,7 @@ class JSBSIM_API FGLogConsole : public FGLogger { buffer.append("\nIn file " + filename + ": line " + std::to_string(line) + "\n"); } void Format(LogFormat format) override; void Flush(void) override; + ~FGLogConsole() override { Flush(); } void Message(const std::string& message) override { if (log_level < min_level) return; @@ -166,7 +172,7 @@ class JSBSIM_API FGLogConsole : public FGLogger class JSBSIM_API LogException : public BaseException, public FGLogging { public: - LogException(std::shared_ptr logger); + LogException(); LogException(LogException& other); const char* what() const noexcept override; }; @@ -174,7 +180,9 @@ class JSBSIM_API LogException : public BaseException, public FGLogging class JSBSIM_API XMLLogException : public LogException { public: - XMLLogException(std::shared_ptr logger, Element* el); + // Construct an XMLLogException using the current thread-local logger + // and the supplied Element to add file/line location information. + XMLLogException(Element* el); /// This constructor can promote a LogException to an XMLLogException /// by adding the file location information to the exception. /// This is useful to add some context to an exception that was thrown in a diff --git a/src/input_output/FGModelLoader.cpp b/src/input_output/FGModelLoader.cpp index 6c0a85d76..d99fa9359 100644 --- a/src/input_output/FGModelLoader.cpp +++ b/src/input_output/FGModelLoader.cpp @@ -68,7 +68,7 @@ Element_ptr FGModelLoader::Open(Element *el) else { document = XMLFileRead.LoadXMLDocument(path); if (document == 0L) { - FGXMLLogging log(model->GetExec()->GetLogger(), el, LogLevel::ERROR); + FGXMLLogging log(el, LogLevel::ERROR); log << "Could not open file: " << fname << endl; return NULL; } diff --git a/src/input_output/FGOutputFG.cpp b/src/input_output/FGOutputFG.cpp index fe2374e02..dcc3a8875 100644 --- a/src/input_output/FGOutputFG.cpp +++ b/src/input_output/FGOutputFG.cpp @@ -121,7 +121,7 @@ FGOutputFG::FGOutputFG(FGFDMExec* fdmex) : memset(&fgSockBuf, 0x0, sizeof(fgSockBuf)); if (fdmex->GetDebugLevel() > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); // Engine status if (Propulsion->GetNumEngines() > FGNetFDM::FG_MAX_ENGINES) log << "This vehicle has " << Propulsion->GetNumEngines() << " engines, but the current \n" diff --git a/src/input_output/FGOutputTextFile.cpp b/src/input_output/FGOutputTextFile.cpp index 4e36cc142..e629455ae 100644 --- a/src/input_output/FGOutputTextFile.cpp +++ b/src/input_output/FGOutputTextFile.cpp @@ -86,7 +86,7 @@ bool FGOutputTextFile::OpenFile(void) datafile.clear(); datafile.open(Filename); if (!datafile) { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << LogFormat::RED << LogFormat::BOLD << "\nERROR: unable to open the file " << LogFormat::RESET << Filename.c_str() << LogFormat::RED << LogFormat::BOLD << "\n => Output to this file is disabled.\n\n" diff --git a/src/input_output/FGOutputType.cpp b/src/input_output/FGOutputType.cpp index 454ff7314..3bb7b50a4 100644 --- a/src/input_output/FGOutputType.cpp +++ b/src/input_output/FGOutputType.cpp @@ -132,7 +132,7 @@ bool FGOutputType::Load(Element* element) string property_str = property_element->GetDataLine(); SGPropertyNode* node = PropertyManager->GetNode(property_str); if (!node) { - FGXMLLogging log(FDMExec->GetLogger(), property_element, LogLevel::ERROR); + FGXMLLogging log(property_element, LogLevel::ERROR); log << LogFormat::RED << LogFormat::BOLD << " No property by the name " << property_str << " has been defined. This property will " << "not be logged. You should check your configuration file.\n" @@ -144,7 +144,7 @@ bool FGOutputType::Load(Element* element) if (f) OutputParameters.push_back(new FGFunctionValue(node, f)); else { - FGXMLLogging log(FDMExec->GetLogger(), property_element, LogLevel::ERROR); + FGXMLLogging log(property_element, LogLevel::ERROR); log << LogFormat::RED << LogFormat::BOLD << " No function by the name " << function_str << " has been defined. This property will " << "not be logged. You should check your configuration file.\n" @@ -254,7 +254,7 @@ void FGOutputType::Debug(int from) if (from == 0) { // Constructor } if (from == 2) { - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (SubSystems & ssSimulation) log << " Simulation parameters logged\n"; if (SubSystems & ssAerosurfaces) log << " Aerosurface parameters logged\n"; if (SubSystems & ssRates) log << " Rate parameters logged\n"; @@ -274,7 +274,7 @@ void FGOutputType::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGOutputType\n"; if (from == 1) log << "Destroyed: FGOutputType\n"; } diff --git a/src/input_output/FGUDPInputSocket.cpp b/src/input_output/FGUDPInputSocket.cpp index ca3f1830d..920453f47 100644 --- a/src/input_output/FGUDPInputSocket.cpp +++ b/src/input_output/FGUDPInputSocket.cpp @@ -74,7 +74,7 @@ bool FGUDPInputSocket::Load(Element* el) string property_str = property_element->GetDataLine(); SGPropertyNode* node = PropertyManager->GetNode(property_str); if (!node) { - FGXMLLogging log(FDMExec->GetLogger(), property_element, LogLevel::ERROR); + FGXMLLogging log(property_element, LogLevel::ERROR); log << LogFormat::RED << LogFormat::BOLD << "\n No property by the name " << property_str << " can be found.\n" << LogFormat::RESET; } else { @@ -109,7 +109,7 @@ void FGUDPInputSocket::Read(bool Holding) for (string& token : tokens) values.push_back(atof_locale_c(token)); } catch(InvalidNumber& e) { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << e.what() << "\n"; return; } @@ -122,7 +122,7 @@ void FGUDPInputSocket::Read(bool Holding) // the zeroeth value is the time stamp if ((values.size() - 1) != InputProperties.size()) { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "\nMismatch between UDP input property and value counts.\n"; return; } diff --git a/src/models/FGAccelerations.cpp b/src/models/FGAccelerations.cpp index 79ac7fcda..5bc6e9105 100644 --- a/src/models/FGAccelerations.cpp +++ b/src/models/FGAccelerations.cpp @@ -410,7 +410,7 @@ void FGAccelerations::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGAccelerations\n"; if (from == 1) log << "Destroyed: FGAccelerations\n"; } diff --git a/src/models/FGAerodynamics.cpp b/src/models/FGAerodynamics.cpp index 502379821..c0cb78418 100644 --- a/src/models/FGAerodynamics.cpp +++ b/src/models/FGAerodynamics.cpp @@ -232,7 +232,7 @@ bool FGAerodynamics::Run(bool Holding) break; default: { - LogException err(FDMExec->GetLogger()); + LogException err; err << "\n A proper axis type has NOT been selected. Check " << "your aerodynamics definition.\n"; throw err; @@ -278,7 +278,7 @@ bool FGAerodynamics::Run(bool Holding) break; default: { - LogException err(FDMExec->GetLogger()); + LogException err; err << "\n A proper axis type has NOT been selected. Check " << "your aerodynamics definition.\n"; throw err; @@ -380,7 +380,7 @@ bool FGAerodynamics::Load(Element *document) ca.push_back(new FGFunction(FDMExec, function_element)); } catch (BaseException& e) { string current_func_name = function_element->GetAttributeValue("name"); - FGXMLLogging log(FDMExec->GetLogger(), axis_element, LogLevel::ERROR); + FGXMLLogging log(axis_element, LogLevel::ERROR); log << LogFormat::RED << "\nError loading aerodynamic function in " << current_func_name << ":" << e.what() << " Aborting.\n" << LogFormat::RESET; return false; @@ -453,25 +453,25 @@ void FGAerodynamics::DetermineAxisSystem(Element* document) } else if (axis == "LIFT" || axis == "DRAG") { if (forceAxisType == atNone) forceAxisType = atWind; else if (forceAxisType != atWind) { - FGXMLLogging log(FDMExec->GetLogger(), axis_element, LogLevel::WARN); + FGXMLLogging log(axis_element, LogLevel::WARN); log << "\n Mixed aerodynamic axis systems have been used in the" << " aircraft config file. (LIFT DRAG)\n"; } } else if (axis == "SIDE") { if (forceAxisType != atNone && forceAxisType != atWind && forceAxisType != atBodyAxialNormal) { - FGXMLLogging log(FDMExec->GetLogger(), axis_element, LogLevel::WARN); + FGXMLLogging log(axis_element, LogLevel::WARN); log << "\n Mixed aerodynamic axis systems have been used in the" << " aircraft config file. (SIDE)\n"; } } else if (axis == "AXIAL" || axis == "NORMAL") { if (forceAxisType == atNone) forceAxisType = atBodyAxialNormal; else if (forceAxisType != atBodyAxialNormal) { - FGXMLLogging log(FDMExec->GetLogger(), axis_element, LogLevel::WARN); + FGXMLLogging log(axis_element, LogLevel::WARN); log << "\n Mixed aerodynamic axis systems have been used in the" << " aircraft config file. (NORMAL AXIAL)\n"; } } else { // error - XMLLogException err(FDMExec->GetLogger(), axis_element); + XMLLogException err(axis_element); err << "\n An unknown axis type, " << axis << " has been specified" << " in the aircraft configuration file.\n"; throw err; @@ -481,13 +481,13 @@ void FGAerodynamics::DetermineAxisSystem(Element* document) if (forceAxisType == atNone) { forceAxisType = atWind; - FGLogging log(FDMExec->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "\n The aerodynamic axis system has been set by default" << " to the Lift/Side/Drag system.\n"; } if (momentAxisType == atNone) { momentAxisType = atBodyXYZ; - FGLogging log(FDMExec->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "\n The aerodynamic moment axis system has been set by default" << " to the bodyXYZ system.\n"; } @@ -502,7 +502,7 @@ void FGAerodynamics::ProcessAxesNameAndFrame(eAxisType& axisType, const string& if (frame == "BODY" || frame.empty()) { if (axisType == atNone) axisType = atBodyXYZ; else if (axisType != atBodyXYZ) { - FGXMLLogging log(FDMExec->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "\n Mixed aerodynamic axis systems have been used in the " << " aircraft config file." << validNames << " - BODY\n"; } @@ -510,7 +510,7 @@ void FGAerodynamics::ProcessAxesNameAndFrame(eAxisType& axisType, const string& else if (frame == "STABILITY") { if (axisType == atNone) axisType = atStability; else if (axisType != atStability) { - FGXMLLogging log(FDMExec->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "\n Mixed aerodynamic axis systems have been used in the " << " aircraft config file." << validNames << " - STABILITY\n"; } @@ -518,13 +518,13 @@ void FGAerodynamics::ProcessAxesNameAndFrame(eAxisType& axisType, const string& else if (frame == "WIND") { if (axisType == atNone) axisType = atWind; else if (axisType != atWind){ - FGXMLLogging log(FDMExec->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "\n Mixed aerodynamic axis systems have been used in the " << " aircraft config file." << validNames << " - WIND\n"; } } else { - XMLLogException err(FDMExec->GetLogger(), el); + XMLLogException err(el); err << "\n Unknown axis frame type of - " << frame << "\n"; throw err; } @@ -685,7 +685,7 @@ void FGAerodynamics::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 2) { // Loader - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); switch (forceAxisType) { case (atWind): log << "\n Aerodynamics (Lift|Side|Drag axes):\n\n"; @@ -706,7 +706,7 @@ void FGAerodynamics::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGAerodynamics\n"; if (from == 1) log << "Destroyed: FGAerodynamics\n"; } diff --git a/src/models/FGAircraft.cpp b/src/models/FGAircraft.cpp index 8b473aaec..a7c7e6337 100644 --- a/src/models/FGAircraft.cpp +++ b/src/models/FGAircraft.cpp @@ -223,7 +223,7 @@ void FGAircraft::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 2) { // Loading - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Aircraft Metrics:\n" << fixed; log << " WingArea: " << WingArea << "\n"; log << " WingSpan: " << WingSpan << "\n"; @@ -239,7 +239,7 @@ void FGAircraft::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGAircraft\n"; if (from == 1) log << "Destroyed: FGAircraft\n"; } diff --git a/src/models/FGAtmosphere.cpp b/src/models/FGAtmosphere.cpp index 2cfa749e6..0cd41af8c 100644 --- a/src/models/FGAtmosphere.cpp +++ b/src/models/FGAtmosphere.cpp @@ -107,7 +107,7 @@ double FGAtmosphere::ValidatePressure(double p, const string& msg, bool quiet) c const double MinPressure = ConvertToPSF(1E-15, ePascals); if (p < MinPressure) { if (!quiet) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << msg << " " << p << " is too low." << endl << msg << " will be capped to " << MinPressure << endl; } @@ -128,7 +128,7 @@ double FGAtmosphere::ValidateTemperature(double t, const string& msg, bool quiet if (t < minUniverseTemperature) { if (!quiet) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << msg << " " << t << " is too low." << endl << msg << " will be capped to " << minUniverseTemperature << endl; } @@ -359,7 +359,7 @@ void FGAtmosphere::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGAtmosphere" << std::endl; if (from == 1) log << "Destroyed: FGAtmosphere" << std::endl; } diff --git a/src/models/FGAuxiliary.cpp b/src/models/FGAuxiliary.cpp index c44ddcbc6..1f2e4de75 100644 --- a/src/models/FGAuxiliary.cpp +++ b/src/models/FGAuxiliary.cpp @@ -391,7 +391,7 @@ double FGAuxiliary::GetDistanceRelativePosition(void) const //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% const FGColumnVector3& FGAuxiliary::GetNEUPositionFromStart() const -{ +{ if (!NEUCalcValid) { // Position tracking in local frame with local frame origin at lat, lon of initial condition // and at 0 altitude relative to the reference ellipsoid. Position is NEU (North, East, UP) in feet. @@ -400,7 +400,7 @@ const FGColumnVector3& FGAuxiliary::GetNEUPositionFromStart() const NEUCalcValid = true; } - return vNEUFromStart; + return vNEUFromStart; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -475,7 +475,7 @@ void FGAuxiliary::bind(void) double FGAuxiliary::BadUnits(void) const { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Bad units" << endl; return 0.0; } @@ -509,7 +509,7 @@ void FGAuxiliary::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGAuxiliary" << endl; if (from == 1) log << "Destroyed: FGAuxiliary" << endl; } @@ -518,7 +518,7 @@ void FGAuxiliary::Debug(int from) if (debug_lvl & 8 ) { // Runtime state variables } if (debug_lvl & 16) { // Sanity checking - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (Mach > 100 || Mach < 0.00) log << "FGPropagate::Mach is out of bounds: " << Mach << endl; if (qbar > 1e6 || qbar < 0.00) diff --git a/src/models/FGBuoyantForces.cpp b/src/models/FGBuoyantForces.cpp index 2865958ef..de0e2baac 100644 --- a/src/models/FGBuoyantForces.cpp +++ b/src/models/FGBuoyantForces.cpp @@ -282,12 +282,12 @@ void FGBuoyantForces::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 2) { // Loader - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Buoyant Forces: \n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGBuoyantForces\n"; if (from == 1) log << "Destroyed: FGBuoyantForces\n"; } diff --git a/src/models/FGExternalForce.cpp b/src/models/FGExternalForce.cpp index a1b404fee..8530f20a8 100644 --- a/src/models/FGExternalForce.cpp +++ b/src/models/FGExternalForce.cpp @@ -93,7 +93,7 @@ FGParameter* FGExternalForce::bind(Element *el, const string& magName, // Set frame (from FGForce). string sFrame = el->GetAttributeValue("frame"); if (sFrame.empty()) { - FGXMLLogging log(fdmex->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "No frame specified for external " << el->GetName() << ", \"" << Name << "\".\nFrame set to Body\n"; ttype = tNone; @@ -106,7 +106,7 @@ FGParameter* FGExternalForce::bind(Element *el, const string& magName, } else if (sFrame == "INERTIAL") { ttype = tInertialBody; } else { - FGXMLLogging log(fdmex->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "Invalid frame specified for external " << el->GetName() << ", \"" << Name << "\".\nFrame set to Body\n"; ttype = tNone; @@ -114,7 +114,7 @@ FGParameter* FGExternalForce::bind(Element *el, const string& magName, Element* direction_element = el->FindElement("direction"); if (!direction_element) { - FGXMLLogging log(fdmex->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "No direction element specified in " << el->GetName() << " object. Default is (0,0,0).\n"; } else { @@ -153,7 +153,7 @@ void FGExternalForce::setForce(Element *el) Element* location_element = el->FindElement("location"); if (!location_element) { - FGXMLLogging log(fdmex->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "No location element specified in force object.\n"; } else { FGColumnVector3 location = location_element->FindElementTripletConvertTo("IN"); @@ -228,7 +228,7 @@ void FGExternalForce::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " " << Name; log << "\n Frame: "; switch(ttype) { @@ -252,7 +252,7 @@ void FGExternalForce::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGExternalForce\n"; if (from == 1) log << "Destroyed: FGExternalForce\n"; } diff --git a/src/models/FGExternalReactions.cpp b/src/models/FGExternalReactions.cpp index 36cb1a895..b58e9f9ff 100644 --- a/src/models/FGExternalReactions.cpp +++ b/src/models/FGExternalReactions.cpp @@ -174,12 +174,12 @@ void FGExternalReactions::Debug(int from) if (from == 0) { // Constructor - loading and initialization } if (from == 2) { // Loading - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n External Reactions: \n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGExternalReactions\n"; if (from == 1) log << "Destroyed: FGExternalReactions\n"; } diff --git a/src/models/FGFCS.cpp b/src/models/FGFCS.cpp index c88919447..539674630 100644 --- a/src/models/FGFCS.cpp +++ b/src/models/FGFCS.cpp @@ -168,7 +168,7 @@ bool FGFCS::Run(bool Holding) // Execute system channels in order for (i=0; iGetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Executing System Channel: " << SystemChannels[i]->GetName() << endl; } ChannelRate = SystemChannels[i]->GetRate(); @@ -326,7 +326,7 @@ void FGFCS::SetThrottleCmd(int engineNum, double setting) ThrottleCmd[engineNum] = setting; } } else { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size() << " engines exist, but attempted throttle command is for engine " << engineNum << endl; @@ -345,7 +345,7 @@ void FGFCS::SetThrottlePos(int engineNum, double setting) ThrottlePos[engineNum] = setting; } } else { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size() << " engines exist, but attempted throttle position setting is for engine " << engineNum << endl; @@ -358,13 +358,13 @@ double FGFCS::GetThrottleCmd(int engineNum) const { if (engineNum < (int)ThrottleCmd.size()) { if (engineNum < 0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Cannot get throttle value for ALL engines" << endl; } else { return ThrottleCmd[engineNum]; } } else { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Throttle " << engineNum << " does not exist! " << ThrottleCmd.size() << " engines exist, but throttle setting for engine " << engineNum << " is selected" << endl; @@ -378,13 +378,13 @@ double FGFCS::GetThrottlePos(int engineNum) const { if (engineNum < (int)ThrottlePos.size()) { if (engineNum < 0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Cannot get throttle value for ALL engines" << endl; } else { return ThrottlePos[engineNum]; } } else { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Throttle " << engineNum << " does not exist! " << ThrottlePos.size() << " engines exist, but attempted throttle position setting is for engine " << engineNum << endl; @@ -516,7 +516,7 @@ bool FGFCS::Load(Element* document) if (sOnOffProperty.length() > 0) { SGPropertyNode* OnOffPropertyNode = PropertyManager->GetNode(sOnOffProperty); if (OnOffPropertyNode == nullptr) { - XMLLogException err(FDMExec->GetLogger(), channel_element); + XMLLogException err(channel_element); err << LogFormat::BOLD << LogFormat::RED << "The On/Off property, " << sOnOffProperty << " specified for channel " << channel_element->GetAttributeValue("name") << " is undefined or not " @@ -531,7 +531,7 @@ bool FGFCS::Load(Element* document) SystemChannels.push_back(newChannel); if (debug_lvl > 0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << endl << LogFormat::BOLD << LogFormat::BLUE << " Channel " << LogFormat::NORMAL << channel_element->GetAttributeValue("name") << LogFormat::RESET << endl; } @@ -566,7 +566,7 @@ bool FGFCS::Load(Element* document) // is equivalent to Element* c1_el = component_element->FindElement("c1"); if (!c1_el) { - XMLLogException err(FDMExec->GetLogger(), component_element); + XMLLogException err(component_element); err << "INTEGRATOR component " << component_element->GetAttributeValue("name") << " does not provide the parameter " << endl; throw err; @@ -596,11 +596,11 @@ bool FGFCS::Load(Element* document) } else if (component_element->GetName() == string("linear_actuator")) { newChannel->Add(new FGLinearActuator(this, component_element)); } else { - FGXMLLogging log(FDMExec->GetLogger(), component_element, LogLevel::ERROR); + FGXMLLogging log(component_element, LogLevel::ERROR); log << "Unknown FCS component: " << component_element->GetName() << endl; } } catch(string& s) { - FGXMLLogging log(FDMExec->GetLogger(), component_element, LogLevel::ERROR); + FGXMLLogging log(component_element, LogLevel::ERROR); log << LogFormat::BOLD << LogFormat::RED << endl << " " << s << endl; log << LogFormat::RESET << endl; return false; @@ -832,13 +832,13 @@ void FGFCS::Debug(int from) if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 2) { // Loader log << endl << " " << Name << endl; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGFCS" << endl; if (from == 1) log << "Destroyed: FGFCS" << endl; } diff --git a/src/models/FGFCSChannel.h b/src/models/FGFCSChannel.h index 4944d9eee..b434791ea 100644 --- a/src/models/FGFCSChannel.h +++ b/src/models/FGFCSChannel.h @@ -100,7 +100,7 @@ class FGFCSChannel { if (i < GetNumComponents()) { return FCSComponents[i]; } else { - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Tried to get nonexistent component\n"; return nullptr; } diff --git a/src/models/FGGasCell.cpp b/src/models/FGGasCell.cpp index 06ccbeaf4..04b1e9203 100644 --- a/src/models/FGGasCell.cpp +++ b/src/models/FGGasCell.cpp @@ -84,7 +84,7 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num, if (element) { vXYZ = element->FindElementTripletConvertTo("IN"); } else { - XMLLogException err(exec->GetLogger(), el); + XMLLogException err(el); err << "\nFatal Error: No location found for this gas cell.\n"; throw err; } @@ -124,7 +124,7 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num, // Cylindrical volume. MaxVolume = M_PI * Yradius * Zradius * Xwidth; } else { - FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "Unsupported gas cell shape.\n"; MaxVolume = (4.0 * M_PI * Xradius * Yradius * Zradius / 3.0 + @@ -137,7 +137,7 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num, Xwidth * Ywidth * Zwidth); } } else { - XMLLogException err(exec->GetLogger(), el); + XMLLogException err(el); err << "\nGas cell shape must be given.\n"; throw err; } @@ -150,7 +150,7 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num, if (0 <= Fullness) { Volume = Fullness * MaxVolume; } else { - FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "Invalid initial gas cell fullness value.\n"; } } @@ -448,7 +448,7 @@ void FGGasCell::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Gas cell holds " << std::fixed << Contents << " mol " << type << "\n"; log << " Cell location (X, Y, Z) (in.): " << vXYZ(eX) << ", " << vXYZ(eY) << ", " << vXYZ(eZ) << "\n"; @@ -466,14 +466,14 @@ void FGGasCell::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(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 - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " " << type << " cell holds " << std::fixed << Contents << " mol\n"; log << " Temperature: " << Temperature << " Rankine\n"; log << " Pressure: " << Pressure << " lbs/ft2\n"; @@ -519,7 +519,7 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, if (element) { vXYZ = element->FindElementTripletConvertTo("IN"); } else { - XMLLogException err(exec->GetLogger(), el); + XMLLogException err(el); err << "\nFatal Error: No location found for this ballonet.\n"; throw err; } @@ -559,7 +559,7 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, // Cylindrical volume. MaxVolume = M_PI * Yradius * Zradius * Xwidth; } else { - FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "Unsupported ballonet shape.\n"; MaxVolume = (4.0 * M_PI * Xradius * Yradius * Zradius / 3.0 + @@ -572,7 +572,7 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, Xwidth * Ywidth * Zwidth); } } else { - XMLLogException err(exec->GetLogger(), el); + XMLLogException err(el); err << "\nFatal Error: Ballonet shape must be given.\n"; throw err; } @@ -585,7 +585,7 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num, if (0 <= Fullness) { Volume = Fullness * MaxVolume; } else { - FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN); + FGXMLLogging log(el, LogLevel::WARN); log << "Invalid initial ballonet fullness value.\n"; } } @@ -800,7 +800,7 @@ void FGBallonet::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(MassBalance->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Ballonet holds " << std::fixed << Contents << " mol air\n"; log << " Location (X, Y, Z) (in.): " << vXYZ(eX) << ", " << vXYZ(eY) << ", " << vXYZ(eZ) << "\n"; @@ -819,14 +819,14 @@ void FGBallonet::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(MassBalance->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(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 - FGLogging log(MassBalance->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Ballonet holds " << std::fixed << Contents << " mol air\n"; log << " Temperature: " << Temperature << " Rankine\n"; log << " Pressure: " << Pressure << " lbs/ft2\n"; diff --git a/src/models/FGGroundReactions.cpp b/src/models/FGGroundReactions.cpp index c707440cd..73377d16a 100644 --- a/src/models/FGGroundReactions.cpp +++ b/src/models/FGGroundReactions.cpp @@ -273,12 +273,12 @@ void FGGroundReactions::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 2) { // Loading - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Ground Reactions: \n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGGroundReactions\n"; if (from == 1) log << "Destroyed: FGGroundReactions\n"; } diff --git a/src/models/FGInertial.cpp b/src/models/FGInertial.cpp index d8dabe4e2..4ddb35dcd 100644 --- a/src/models/FGInertial.cpp +++ b/src/models/FGInertial.cpp @@ -121,7 +121,7 @@ bool FGInertial::Load(Element* el) // Messages to warn the user about possible inconsistencies. if (debug_lvl > 0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); if (a != b && J2 == 0.0) log << "Gravitational constant J2 is null for a non-spherical planet." << endl; if (a == b && J2 != 0.0) @@ -242,7 +242,7 @@ void FGInertial::SetAltitudeAGL(FGLocation& location, double altitudeAGL) void FGInertial::SetGravityType(int gt) { // Messages to warn the user about possible inconsistencies. - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); switch (gt) { case eGravType::gtStandard: @@ -291,7 +291,7 @@ void FGInertial::Debug(int from) if (debug_lvl <= 0) return; if (debug_lvl & 1) { // Standard console startup message output - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) {} // Constructor if (from == 2) { // Loading log << endl << " Planet " << Name << endl @@ -303,7 +303,7 @@ void FGInertial::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGInertial" << endl; if (from == 1) log << "Destroyed: FGInertial" << endl; } diff --git a/src/models/FGInput.cpp b/src/models/FGInput.cpp index 2054713d6..9688afc6e 100644 --- a/src/models/FGInput.cpp +++ b/src/models/FGInput.cpp @@ -94,7 +94,7 @@ bool FGInput::Load(Element* el) FGInputType* Input = 0; if (debug_lvl > 0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << endl << " Input data set: " << idx << " " << endl; } @@ -105,7 +105,7 @@ bool FGInput::Load(Element* el) } else if (type == "QTJSBSIM") { Input = new FGUDPInputSocket(FDMExec); } else if (type != string("NONE")) { - FGXMLLogging log(FDMExec->GetLogger(), element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << "Unknown type of input specified in config file" << endl; } @@ -158,14 +158,14 @@ bool FGInput::SetDirectivesFile(const SGPath& fname) FGXMLFileRead XMLFile; Element* document = XMLFile.LoadXMLDocument(fname); if (!document) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "Could not read directive file: " << fname << endl; throw err; } bool result = Load(document); if (!result) { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << endl << "Aircraft input element has problems in file " << fname << endl; } @@ -236,7 +236,7 @@ void FGInput::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGInput" << endl; if (from == 1) log << "Destroyed: FGInput" << endl; } diff --git a/src/models/FGLGear.cpp b/src/models/FGLGear.cpp index 57d325156..8b509db92 100644 --- a/src/models/FGLGear.cpp +++ b/src/models/FGLGear.cpp @@ -174,7 +174,7 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number, const struct Inputs& ForceY_Table = new FGTable(PropertyManager, force_table); break; } else { - FGXMLLogging log(fdmex->GetLogger(), force_table, LogLevel::ERROR); + FGXMLLogging log(force_table, LogLevel::ERROR); log << "Undefined force table for " << name << " contact point\n"; } force_table = el->FindNextElement("table"); @@ -183,7 +183,7 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number, const struct Inputs& Element* element = el->FindElement("location"); if (element) vXYZn = element->FindElementTripletConvertTo("IN"); else { - XMLLogException err(fdmex->GetLogger(), el); + XMLLogException err(el); err << "\nNo location given for contact " << name << "\n"; throw err; } @@ -211,7 +211,7 @@ FGLGear::FGLGear(Element* el, FGFDMExec* fdmex, int number, const struct Inputs& else if (sBrakeGroup == "NONE" ) eBrakeGrp = bgNone; else if (sBrakeGroup.empty() ) eBrakeGrp = bgNone; else { - FGXMLLogging log(fdmex->GetLogger(), el, LogLevel::ERROR); + FGXMLLogging log(el, LogLevel::ERROR); log << "Improper braking group specification in config file: " << sBrakeGroup << " is undefined.\n"; } @@ -550,7 +550,7 @@ void FGLGear::ReportTakeoffOrLanding(void) if (lastWOW != WOW) { if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "GEAR_CONTACT: " << fixed << fdmex->GetSimTime() << " seconds: " << name << " " << WOW << "\n"; } @@ -568,7 +568,7 @@ void FGLGear::CrashDetect(void) SinkRate > 1.4666*30 ) && !fdmex->IntegrationSuspended()) { if (debug_lvl > 0) { - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "*CRASH DETECTED* " << fixed << fdmex->GetSimTime() << " seconds: " << name << "\n"; } @@ -868,7 +868,7 @@ void FGLGear::Report(ReportType repType) { if (fabs(TakeoffDistanceTraveled) < 0.001) return; // Don't print superfluous reports - FGLogging log(fdmex->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); switch(repType) { case erLand: @@ -933,7 +933,7 @@ 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); + FGLogging log(LogLevel::DEBUG); if (from == 0) { // Constructor - loading and initialization log << " " << sContactType[eContactType] << " " << name << "\n" << fixed; log << " Location: " << vXYZn << "\n"; @@ -961,7 +961,7 @@ void FGLGear::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGLGear\n"; if (from == 1) log << "Destroyed: FGLGear\n"; } diff --git a/src/models/FGMassBalance.cpp b/src/models/FGMassBalance.cpp index 367806d25..e2207fdaf 100644 --- a/src/models/FGMassBalance.cpp +++ b/src/models/FGMassBalance.cpp @@ -269,7 +269,7 @@ void FGMassBalance::AddPointMass(Element* el) Element* loc_element = el->FindElement("location"); string pointmass_name = el->GetAttributeValue("name"); if (!loc_element) { - XMLLogException err(FDMExec->GetLogger(), el); + XMLLogException err(el); err << "Pointmass " << pointmass_name << " has no location." << endl; throw err; } @@ -436,7 +436,7 @@ void FGMassBalance::PointMass::bind(FGPropertyManager* PropertyManager, void FGMassBalance::GetMassPropertiesReport(int i) { - FGLogging log(FDMExec->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << endl << LogFormat::BLUE << LogFormat::BOLD << " Mass Properties Report (English units: lbf, in, slug-ft^2)" << LogFormat::RESET << endl; @@ -501,7 +501,7 @@ void FGMassBalance::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 2) { // Loading - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << endl << " Mass and Balance:" << endl << fixed; log << " baseIxx: " << baseJ(1,1) << " slug-ft2" << endl; log << " baseIyy: " << baseJ(2,2) << " slug-ft2" << endl; @@ -521,7 +521,7 @@ void FGMassBalance::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGMassBalance" << endl; if (from == 1) log << "Destroyed: FGMassBalance" << endl; } @@ -531,7 +531,7 @@ void FGMassBalance::Debug(int from) } if (debug_lvl & 16) { // Sanity checking if (from == 2) { - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (EmptyWeight <= 0.0 || EmptyWeight > 1e9) log << "MassBalance::EmptyWeight out of bounds: " << EmptyWeight << endl; if (Weight <= 0.0 || Weight > 1e9) diff --git a/src/models/FGModel.cpp b/src/models/FGModel.cpp index d3ac34f33..7b76d9a2f 100644 --- a/src/models/FGModel.cpp +++ b/src/models/FGModel.cpp @@ -116,7 +116,7 @@ bool FGModel::Upload(Element* el, bool preLoad) if (!document) return false; if (document->GetName() != el->GetName()) { - FGXMLLogging log(FDMExec->GetLogger(), el, LogLevel::ERROR); + FGXMLLogging log(el, LogLevel::ERROR); log << " Read model '" << document->GetName() << "' while expecting model '" << el->GetName() << "'" << endl; return false; @@ -178,12 +178,12 @@ void FGModel::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGModel" << endl; if (from == 1) log << "Destroyed: FGModel" << endl; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from ==2) log << "Entering Run() for model " << Name << endl; } if (debug_lvl & 8 ) { // Runtime state variables diff --git a/src/models/FGOutput.cpp b/src/models/FGOutput.cpp index 9bf6ba4dc..9a8d47d63 100644 --- a/src/models/FGOutput.cpp +++ b/src/models/FGOutput.cpp @@ -175,14 +175,14 @@ bool FGOutput::SetDirectivesFile(const SGPath& fname) FGXMLFileRead XMLFile; Element* document = XMLFile.LoadXMLDocument(fname); if (!document) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "Could not read directive file: " << fname; throw err; } bool result = Load(document); if (!result) { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "\nAircraft output element has problems in file " << fname << "\n"; } @@ -199,7 +199,7 @@ bool FGOutput::Load(int subSystems, std::string protocol, std::string type, FGOutputType* Output = 0; if (debug_lvl > 0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Output data set: " << idx << "\n"; } @@ -222,7 +222,7 @@ bool FGOutput::Load(int subSystems, std::string protocol, std::string type, } else if (type == "TERMINAL") { // Not done yet } else if (type != string("NONE")) { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Unknown type of output specified in config file\n"; } @@ -256,7 +256,7 @@ bool FGOutput::Load(Element* document, const SGPath& dir) FGOutputType* Output = 0; if (debug_lvl > 0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Output data set: " << idx << " \n"; } @@ -273,7 +273,7 @@ bool FGOutput::Load(Element* document, const SGPath& dir) } else if (type == "TERMINAL") { // Not done yet } else if (type != string("NONE")) { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Unknown type of output specified in config file\n"; } @@ -334,7 +334,7 @@ void FGOutput::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGOutput\n"; if (from == 1) log << "Destroyed: FGOutput\n"; } diff --git a/src/models/FGPropagate.cpp b/src/models/FGPropagate.cpp index c6d9cef7d..b966fe592 100644 --- a/src/models/FGPropagate.cpp +++ b/src/models/FGPropagate.cpp @@ -361,7 +361,7 @@ void FGPropagate::Integrate( FGColumnVector3& Integrand, case eBuss2: case eLocalLinearization: { - LogException err(FDMExec->GetLogger()); + LogException err; err << "Can only use Buss (1 & 2) or local linearization integration methods in for rotational position!"; throw err; } @@ -457,7 +457,7 @@ void FGPropagate::Integrate( FGQuaternion& Integrand, double J = C2p*qk + C3p*qdotk - C4*Cp; double K = C2p*pk + C3p*pdotk - C4*Dp; - FGLogging log(FDMExec->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "q: " << q << "\n"; // Warning! In the paper of Barker et al. the quaternion components are not @@ -707,7 +707,7 @@ FGColumnVector3 FGPropagate::GetEulerDeg(void) const void FGPropagate::DumpState(void) { - FGLogging log(FDMExec->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "\n"; log << LogFormat::BLUE << "------------------------------------------------------------------" << LogFormat::RESET << "\n"; @@ -773,7 +773,7 @@ void FGPropagate::WriteStateFile(int num) outfile << "\n"; outfile.close(); } else { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Could not open and/or write the state to the initial conditions file: " << path << "\n"; } @@ -811,13 +811,13 @@ void FGPropagate::WriteStateFile(int num) outfile << "\n"; outfile.close(); } else { - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Could not open and/or write the state to the initial conditions file: " << path << "\n"; } break; default: - FGLogging log(FDMExec->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "When writing a state file, the supplied value must be 1 or 2 for the version number of the resulting IC file\n"; } } @@ -946,14 +946,14 @@ void FGPropagate::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGPropagate\n"; if (from == 1) log << "Destroyed: FGPropagate\n"; } if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects } if (debug_lvl & 8 && from == 2) { // Runtime state variables - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n" << LogFormat::BLUE << LogFormat::BOLD << left << fixed << " Propagation Report (English units: ft, degrees) at simulation time " << FDMExec->GetSimTime() << " seconds" << LogFormat::RESET << "\n\n"; @@ -1043,17 +1043,17 @@ void FGPropagate::Debug(int from) if (debug_lvl & 16) { // Sanity checking if (from == 2) { // State sanity checking if (fabs(VState.vPQR.Magnitude()) > 1000.0) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "Vehicle rotation rate is excessive (>1000 rad/sec): " << VState.vPQR.Magnitude() << "\n"; throw err; } if (fabs(VState.vUVW.Magnitude()) > 1.0e10) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "Vehicle velocity is excessive (>1e10 ft/sec): " << VState.vUVW.Magnitude() << "\n"; throw err; } if (fabs(GetDistanceAGL()) > 1e10) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "Vehicle altitude is excessive (>1e10 ft): " << GetDistanceAGL() << "\n"; throw err; } diff --git a/src/models/FGPropulsion.cpp b/src/models/FGPropulsion.cpp index 5d76395a6..3bcbc5079 100644 --- a/src/models/FGPropulsion.cpp +++ b/src/models/FGPropulsion.cpp @@ -319,7 +319,7 @@ void FGPropulsion::InitRunning(int n) if (n >= 0) { // A specific engine is supposed to be initialized if (n >= (int)GetNumEngines() ) { - LogException err(FDMExec->GetLogger()); + LogException err; err << "Tried to initialize a non-existent engine!"; throw err; } @@ -374,7 +374,7 @@ bool FGPropulsion::Load(Element* el) if (tank->GetType() == FGTank::ttFUEL) FuelDensity = tank->GetDensity(); else if (tank->GetType() != FGTank::ttOXIDIZER) { - FGXMLLogging log(FDMExec->GetLogger(), tank_element, LogLevel::ERROR); + FGXMLLogging log(tank_element, LogLevel::ERROR); log << "Unknown tank type specified.\n"; return false; } @@ -393,12 +393,12 @@ bool FGPropulsion::Load(Element* el) // Locate the thruster definition Element* thruster_element = engine_element->FindElement("thruster"); if (!thruster_element) { - XMLLogException err(FDMExec->GetLogger(), engine_element); + XMLLogException err(engine_element); err << "No thruster definition supplied with engine definition."; throw err; } if (!ModelLoader.Open(thruster_element)) { - XMLLogException err(FDMExec->GetLogger(), thruster_element); + XMLLogException err(thruster_element); err << "Cannot open the thruster element."; throw err; } @@ -423,7 +423,7 @@ bool FGPropulsion::Load(Element* el) Engines.push_back(make_shared(FDMExec, element, numEngines, in)); } else { - FGXMLLogging log(FDMExec->GetLogger(), engine_element, LogLevel::ERROR); + FGXMLLogging log(engine_element, LogLevel::ERROR); log << " Unknown engine type\n"; return false; } @@ -435,7 +435,7 @@ bool FGPropulsion::Load(Element* el) err << "Cannot load " << Name << "\n"; return false; } catch (const BaseException& e) { - FGXMLLogging err(FDMExec->GetLogger(), engine_element, LogLevel::FATAL); + FGXMLLogging err(engine_element, LogLevel::FATAL); err << "\n" << LogFormat::RED << e.what() << LogFormat::RESET << "\nCannot load " << Name << "\n"; return false; @@ -883,12 +883,12 @@ void FGPropulsion::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 2) { // Loader - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Propulsion:\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGPropulsion\n"; if (from == 1) log << "Destroyed: FGPropulsion\n"; } diff --git a/src/models/atmosphere/FGMSIS.cpp b/src/models/atmosphere/FGMSIS.cpp index 5558c1a06..d88c070ba 100644 --- a/src/models/atmosphere/FGMSIS.cpp +++ b/src/models/atmosphere/FGMSIS.cpp @@ -231,14 +231,14 @@ void FGMSIS::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) {} // Constructor if (from == 3) { // Loading - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(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 - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: MSIS\n"; if (from == 1) log << "Destroyed: MSIS\n"; } diff --git a/src/models/atmosphere/FGMars.cpp b/src/models/atmosphere/FGMars.cpp index f6d3c2a55..24bf7354c 100644 --- a/src/models/atmosphere/FGMars.cpp +++ b/src/models/atmosphere/FGMars.cpp @@ -81,8 +81,8 @@ void FGMars::Calculate(double altitude) Pressure = 14.62*exp(-0.00003*altitude); // psf - 14.62 psf =~ 7 millibars Density = Pressure/(Reng*Temperature); // slugs/ft^3 (needs deg R. as input - //FGLogging log(FDMExec->GetLogger(), LogLevel::INFO); - //log << "Atmosphere: h=" << altitude << " rho= " << intDensity << "\n"; + //FGLogging log(LogLevel::INFO); + //log << "Atmosphere: h=" << altitude << " rho= " << Density << "\n"; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -113,7 +113,7 @@ void FGMars::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGMars\n"; if (from == 1) log << "Destroyed: FGMars\n"; } diff --git a/src/models/atmosphere/FGStandardAtmosphere.cpp b/src/models/atmosphere/FGStandardAtmosphere.cpp index 2addc27d5..dbd36b4a0 100644 --- a/src/models/atmosphere/FGStandardAtmosphere.cpp +++ b/src/models/atmosphere/FGStandardAtmosphere.cpp @@ -364,7 +364,7 @@ void FGStandardAtmosphere::SetTemperatureBias(eTemperature unit, double t) // temperature lower than the lowest known temperature in the universe if (minStdAtmosphereTemp + TemperatureBias < minUniverseTemperature) { double minBias = minUniverseTemperature - minStdAtmosphereTemp; - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "The temperature bias " << TemperatureBias << " R is too low. " << "It could result in temperatures below the absolute zero." << endl << "Temperature bias is therefore capped to " << minBias << endl; @@ -415,7 +415,7 @@ void FGStandardAtmosphere::SetTemperatureGradedDelta(double deltemp, double h, e deltemp *= 1.80; // If temp delta "t" is given in metric, scale up to English if (deltemp <= minDeltaTemperature) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "The temperature delta " << deltemp << " R is too low. " << "It could result in temperatures below the absolute zero." << endl << "Temperature delta is therefore capped to " << minDeltaTemperature << endl; @@ -434,7 +434,7 @@ void FGStandardAtmosphere::SetTemperatureGradedDelta(double deltemp, double h, e void FGStandardAtmosphere::PrintStandardAtmosphereTable() { - FGLogging log(FDMExec->GetLogger(), LogLevel::INFO); + FGLogging log(LogLevel::INFO); log << "Altitude (ft) Temp (F) Pressure (psf) Density (sl/ft3)" << std::endl; log << "------------- -------- -------------- ----------------" << std::endl; for (int i=0; i<280000; i+=1000) { @@ -626,7 +626,7 @@ void FGStandardAtmosphere::SetDewPoint(eTemperature unit, double dewpoint) constexpr double minDewPoint = CelsiusToRankine(-c) + 1.0; if (dewPoint_R <= minDewPoint) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "The dew point temperature " << dewPoint_R << " is lower than " << minDewPoint << " R." << endl << "Dew point is therefore capped to " << minDewPoint << endl; @@ -638,7 +638,7 @@ void FGStandardAtmosphere::SetDewPoint(eTemperature unit, double dewpoint) double finalizedDewPoint = GetDewPoint(eRankine); if (finalizedDewPoint < dewPoint_R) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "Dew point temperature has been capped to " << finalizedDewPoint << endl; } @@ -668,12 +668,12 @@ void FGStandardAtmosphere::SetVaporPressure(ePressure unit, double Pa) double altitude = CalculatePressureAltitude(Pressure, 0.0); double VaporPressure = ConvertToPSF(Pa, unit); if (VaporPressure < 0.0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "The vapor pressure cannot be negative." << endl << "Vapor pressure is set to 0.0" << endl; VaporPressure = 0.0; } else if (VaporPressure >= Pressure) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "The vapor pressure " << VaporPressure << " PSF is higher than the ambient pressure." << endl << "Vapor pressure is therefore capped to " << Pressure-1.0 << endl; @@ -711,12 +711,12 @@ double FGStandardAtmosphere::GetRelativeHumidity(void) const void FGStandardAtmosphere::SetRelativeHumidity(double RH) { if (RH < 0.0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "The relative humidity cannot be negative." << endl << "Relative humidity is set to 0%" << endl; RH = 0.0; } else if (RH > 100.0) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "The relative humidity cannot be higher than 100%." << endl << "Relative humidity is set to 100%" << endl; RH = 100.0; @@ -742,7 +742,7 @@ void FGStandardAtmosphere::SetVaporMassFractionPPM(double frac) ValidateVaporMassFraction(altitude); if (fabs(VaporMassFraction*1E6-frac)>1E-2) { - FGLogging log(FDMExec->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "The vapor mass fraction " << frac << " has been capped to " << VaporMassFraction*1E6 << "PPM." << endl; } @@ -805,7 +805,7 @@ void FGStandardAtmosphere::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGStandardAtmosphere" << std::endl; if (from == 1) log << "Destroyed: FGStandardAtmosphere" << std::endl; } diff --git a/src/models/atmosphere/FGWinds.cpp b/src/models/atmosphere/FGWinds.cpp index 983364b89..b6ade15ea 100644 --- a/src/models/atmosphere/FGWinds.cpp +++ b/src/models/atmosphere/FGWinds.cpp @@ -618,7 +618,7 @@ void FGWinds::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGWinds" << endl; if (from == 1) log << "Destroyed: FGWinds" << endl; } diff --git a/src/models/flight_control/FGAccelerometer.cpp b/src/models/flight_control/FGAccelerometer.cpp index bc8c1e89d..1fe882a3d 100644 --- a/src/models/flight_control/FGAccelerometer.cpp +++ b/src/models/flight_control/FGAccelerometer.cpp @@ -52,7 +52,7 @@ CLASS IMPLEMENTATION FGAccelerometer::FGAccelerometer(FGFCS* fcs, Element* element) : FGSensor(fcs, element), - FGSensorOrientation(element, fcs->GetExec()->GetLogger()) + FGSensorOrientation(element) { Propagate = fcs->GetExec()->GetPropagate(); Accelerations = fcs->GetExec()->GetAccelerations(); @@ -62,7 +62,7 @@ FGAccelerometer::FGAccelerometer(FGFCS* fcs, Element* element) if (location_element) vLocation = location_element->FindElementTripletConvertTo("IN"); else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "No location given for accelerometer.\n"; throw err; } @@ -131,12 +131,12 @@ void FGAccelerometer::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Axis: " << ax[axis] << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGAccelerometer\n"; if (from == 1) log << "Destroyed: FGAccelerometer\n"; } diff --git a/src/models/flight_control/FGActuator.cpp b/src/models/flight_control/FGActuator.cpp index 116dcad04..e27ed346c 100644 --- a/src/models/flight_control/FGActuator.cpp +++ b/src/models/flight_control/FGActuator.cpp @@ -337,7 +337,7 @@ void FGActuator::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " INPUT: " << InputNodes[0]->GetNameWithSign() << fixed << setprecision(4) << "\n"; @@ -358,7 +358,7 @@ void FGActuator::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGActuator\n"; if (from == 1) log << "Destroyed: FGActuator\n"; } diff --git a/src/models/flight_control/FGAngles.cpp b/src/models/flight_control/FGAngles.cpp index c952b5a92..f846041e1 100644 --- a/src/models/flight_control/FGAngles.cpp +++ b/src/models/flight_control/FGAngles.cpp @@ -100,7 +100,7 @@ FGAngles::FGAngles(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) } } } else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Target angle is required for Angles component: " << Name << "\n"; throw err; } @@ -113,7 +113,7 @@ FGAngles::FGAngles(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) } } } else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Source angle is required for Angles component: " << Name << "\n"; throw err; } @@ -123,7 +123,7 @@ FGAngles::FGAngles(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) if (unit == "DEG") output_unit = 180.0/M_PI; else if (unit == "RAD") output_unit = 1.0; else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Unknown unit " << unit << " in angle component, " << Name << "\n"; throw err; } @@ -195,8 +195,8 @@ void FGAngles::Debug(int from) if (from == 0) { // Constructor } } - if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + if (debug_lvl & 2 ) { // Instantiation/Destruction notification + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGAngles\n"; if (from == 1) log << "Destroyed: FGAngles\n"; } diff --git a/src/models/flight_control/FGDeadBand.cpp b/src/models/flight_control/FGDeadBand.cpp index 6b6eeec8e..09d17df1d 100644 --- a/src/models/flight_control/FGDeadBand.cpp +++ b/src/models/flight_control/FGDeadBand.cpp @@ -128,7 +128,7 @@ void FGDeadBand::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " INPUT: " << InputNodes[0]->GetName() << "\n"; log << " DEADBAND WIDTH: " << Width->GetName() << "\n"; log << " GAIN: " << fixed << setprecision(4) << gain << "\n"; @@ -138,7 +138,7 @@ void FGDeadBand::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGDeadBand\n"; if (from == 1) log << "Destroyed: FGDeadBand\n"; } diff --git a/src/models/flight_control/FGDistributor.cpp b/src/models/flight_control/FGDistributor.cpp index 5600fcf90..ef145c172 100644 --- a/src/models/flight_control/FGDistributor.cpp +++ b/src/models/flight_control/FGDistributor.cpp @@ -63,7 +63,7 @@ FGDistributor::FGDistributor(FGFCS* fcs, Element* element) if (type_string == "inclusive") Type = eInclusive; else if (type_string == "exclusive") Type = eExclusive; else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Distributor type should be \"inclusive\" or \"exclusive\"" << " but got \"" << type_string << "\" instead.\n"; throw err; @@ -80,7 +80,7 @@ FGDistributor::FGDistributor(FGFCS* fcs, Element* element) } catch (LogException& e) { throw XMLLogException(e, test_element); } catch (const BaseException& e) { - XMLLogException err(fcs->GetExec()->GetLogger(), test_element); + XMLLogException err(test_element); err << LogFormat::RED << e.what() << LogFormat::RESET << "\n\n"; throw err; } @@ -143,7 +143,7 @@ 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); + FGLogging log(LogLevel::DEBUG); unsigned int ctr=0; for (const auto& Case: Cases) { log << " Case: " << fixed << ctr << "\n"; @@ -165,7 +165,7 @@ void FGDistributor::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGDistributor\n"; if (from == 1) log << "Destroyed: FGDistributor\n"; } diff --git a/src/models/flight_control/FGFCSComponent.cpp b/src/models/flight_control/FGFCSComponent.cpp index 3b61bcb92..4325ae9a4 100644 --- a/src/models/flight_control/FGFCSComponent.cpp +++ b/src/models/flight_control/FGFCSComponent.cpp @@ -132,7 +132,7 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) bool node_exists = PropertyManager->HasNode(output_node_name); SGPropertyNode* OutputNode = PropertyManager->GetNode( output_node_name, true ); if (!OutputNode) { - XMLLogException err(fcs->GetExec()->GetLogger(), out_elem); + XMLLogException err(out_elem); err << " Unable to process property: " << output_node_name << "\n"; throw err; } @@ -158,7 +158,7 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) } else if (delayType == "frames") { delay = (unsigned int)delay_time; } else { - FGXMLLogging log(fcs->GetExec()->GetLogger(), delay_elem, LogLevel::ERROR); + FGXMLLogging log(delay_elem, LogLevel::ERROR); log << "Unallowed delay type\n"; } } else { @@ -172,7 +172,7 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) if (clip_el) { Element* el = clip_el->FindElement("min"); if (!el) { - FGXMLLogging log(fcs->GetExec()->GetLogger(), clip_el, LogLevel::ERROR); + FGXMLLogging log(clip_el, LogLevel::ERROR); log << "Element is missing, is ignored.\n"; return; } @@ -181,7 +181,7 @@ FGFCSComponent::FGFCSComponent(FGFCS* _fcs, Element* element) : fcs(_fcs) el = clip_el->FindElement("max"); if (!el) { - FGXMLLogging log(fcs->GetExec()->GetLogger(), clip_el, LogLevel::ERROR); + FGXMLLogging log(clip_el, LogLevel::ERROR); log << "Element is missing, is ignored.\n"; ClipMin = nullptr; return; @@ -221,7 +221,7 @@ void FGFCSComponent::CheckInputNodes(size_t MinNodes, size_t MaxNodes, Element* size_t num = InputNodes.size(); if (num < MinNodes) { - XMLLogException err(fcs->GetExec()->GetLogger(), el); + XMLLogException err(el); err << " Not enough nodes are provided\n" << " Expecting " << MinNodes << " while " << num << " are provided.\n"; @@ -229,7 +229,7 @@ void FGFCSComponent::CheckInputNodes(size_t MinNodes, size_t MaxNodes, Element* } if (num > MaxNodes) { - FGXMLLogging log(fcs->GetExec()->GetLogger(), el, LogLevel::ERROR); + FGXMLLogging log(el, LogLevel::ERROR); log << " Too many nodes are provided\n" << " Expecting " << MaxNodes << " while " << num << " are provided.\n" @@ -272,7 +272,7 @@ void FGFCSComponent::Clip(void) double range = vmax - vmin; if (range < 0.0) { - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::ERROR); + FGLogging log(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" @@ -321,7 +321,7 @@ void FGFCSComponent::bind(Element* el, FGPropertyManager* PropertyManager) node->setDoubleValue(Output); } else { - FGXMLLogging log(fcs->GetExec()->GetLogger(), el, LogLevel::ERROR); + FGXMLLogging log(el, LogLevel::ERROR); log << "Could not get or create property " << tmp << "\n"; } } @@ -351,7 +351,7 @@ void FGFCSComponent::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Loading Component \"" << Name << fixed << "\" of type: " << Type << "\n"; @@ -364,7 +364,7 @@ void FGFCSComponent::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGFCSComponent\n"; if (from == 1) log << "Destroyed: FGFCSComponent\n"; } diff --git a/src/models/flight_control/FGFCSFunction.cpp b/src/models/flight_control/FGFCSFunction.cpp index 458e977ed..d95a12345 100644 --- a/src/models/flight_control/FGFCSFunction.cpp +++ b/src/models/flight_control/FGFCSFunction.cpp @@ -60,7 +60,7 @@ FGFCSFunction::FGFCSFunction(FGFCS* fcs, Element* element) if (function_element) function = new FGFunction(fcs->GetExec(), function_element); else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "FCS Function should contain a \"function\" element\n"; throw err; } @@ -119,7 +119,7 @@ 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); + FGLogging log(LogLevel::DEBUG); if (!InputNodes.empty()) log << " INPUT: " << InputNodes[0]->GetName() << "\n"; for (auto node: OutputNodes) @@ -127,7 +127,7 @@ void FGFCSFunction::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGFCSFunction\n"; if (from == 1) log << "Destroyed: FGFCSFunction\n"; } diff --git a/src/models/flight_control/FGFilter.cpp b/src/models/flight_control/FGFilter.cpp index ff49e28f2..b7b11cd54 100644 --- a/src/models/flight_control/FGFilter.cpp +++ b/src/models/flight_control/FGFilter.cpp @@ -141,7 +141,7 @@ void FGFilter::CalculateDynamicFilters(void) break; case eUnknown: { - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Unknown filter type\n"; } break; @@ -220,7 +220,7 @@ void FGFilter::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " INPUT: " << InputNodes[0]->GetName() << fixed << "\n"; for (int i=1; i < 7; i++) { @@ -236,7 +236,7 @@ void FGFilter::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGFilter\n"; if (from == 1) log << "Destroyed: FGFilter\n"; } diff --git a/src/models/flight_control/FGGain.cpp b/src/models/flight_control/FGGain.cpp index e252434c7..a2c40fe38 100644 --- a/src/models/flight_control/FGGain.cpp +++ b/src/models/flight_control/FGGain.cpp @@ -63,7 +63,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) if (Type == "PURE_GAIN") { if ( !element->FindElement("gain") ) { - FGXMLLogging log(fcs->GetExec()->GetLogger(), element, LogLevel::ERROR); + FGXMLLogging log(element, LogLevel::ERROR); log << LogFormat::BOLD << " No GAIN specified (default: 1.0)\n"; } } @@ -86,7 +86,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) } scale_element = element->FindElement("range"); if (!scale_element) { - XMLLogException err(fcs->GetExec()->GetLogger(), scale_element); + XMLLogException err(scale_element); err << "No range supplied for aerosurface scale component\n"; throw err; } @@ -95,7 +95,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) OutMax = scale_element->FindElementValueAsNumber("max"); OutMin = scale_element->FindElementValueAsNumber("min"); } else { - XMLLogException err(fcs->GetExec()->GetLogger(), scale_element); + XMLLogException err(scale_element); err << "Maximum and minimum output values must be supplied for the " "aerosurface scale component\n"; throw err; @@ -115,7 +115,7 @@ FGGain::FGGain(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) if (element->FindElement("table")) { Table = new FGTable(PropertyManager, element->FindElement("table")); } else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "A table must be provided for the scheduled gain component\n"; throw err; } @@ -198,7 +198,7 @@ void FGGain::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " INPUT: " << InputNodes[0]->GetNameWithSign() << "\n"; log << " GAIN: " << Gain->GetName() << fixed << "\n"; @@ -219,7 +219,7 @@ void FGGain::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGGain\n"; if (from == 1) log << "Destroyed: FGGain\n"; } diff --git a/src/models/flight_control/FGGyro.cpp b/src/models/flight_control/FGGyro.cpp index 81cb6e347..37d22a9f8 100644 --- a/src/models/flight_control/FGGyro.cpp +++ b/src/models/flight_control/FGGyro.cpp @@ -50,7 +50,7 @@ CLASS IMPLEMENTATION FGGyro::FGGyro(FGFCS* fcs, Element* element) : FGSensor(fcs, element), - FGSensorOrientation(element, fcs->GetExec()->GetLogger()) + FGSensorOrientation(element) { Propagate = fcs->GetExec()->GetPropagate(); @@ -111,13 +111,13 @@ 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); + FGLogging log(LogLevel::DEBUG); if (from == 0) { // Constructor log << " Axis: " << ax[axis] << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGGyro\n"; if (from == 1) log << "Destroyed: FGGyro\n"; } diff --git a/src/models/flight_control/FGKinemat.cpp b/src/models/flight_control/FGKinemat.cpp index 1c1acd29c..1d09375b0 100644 --- a/src/models/flight_control/FGKinemat.cpp +++ b/src/models/flight_control/FGKinemat.cpp @@ -71,7 +71,7 @@ FGKinemat::FGKinemat(FGFCS* fcs, Element* element) } if (Detents.size() <= 1) { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "\nKinematic component " << Name << " must have more than 1 setting element\n"; throw err; @@ -178,7 +178,7 @@ 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); + FGLogging log(LogLevel::DEBUG); if (from == 0) { // Constructor log << " INPUT: " << InputNodes[0]->GetName() << "\n"; log << " DETENTS: " << Detents.size() << fixed << setprecision(4) << "\n"; @@ -191,7 +191,7 @@ void FGKinemat::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGKinemat\n"; if (from == 1) log << "Destroyed: FGKinemat\n"; } diff --git a/src/models/flight_control/FGLinearActuator.cpp b/src/models/flight_control/FGLinearActuator.cpp index f3d3b6ecc..f9f2c42fc 100644 --- a/src/models/flight_control/FGLinearActuator.cpp +++ b/src/models/flight_control/FGLinearActuator.cpp @@ -95,7 +95,7 @@ FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element) if (element->FindElement("module")) { module = element->FindElementValueAsNumber("module"); if (module < 0) { - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() << " parameter is forced from " << fixed << module << " value to 1.0 value\n"; @@ -106,7 +106,7 @@ FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element) if (element->FindElement("hysteresis")) { hysteresis = element->FindElementValueAsNumber("hysteresis"); if (hysteresis < 0) { - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() << " parameter is forced from " << fixed << hysteresis << " value to 0.0 value\n"; @@ -123,7 +123,7 @@ FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element) previousLagInput = previousLagOutput = 0.0; } else { if (lag < 0) { - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() << " parameter is forced from " << fixed << lag << " value to 0.0 value\n"; @@ -135,7 +135,7 @@ FGLinearActuator::FGLinearActuator(FGFCS* fcs, Element* element) if (element->FindElement("rate")) { rate = element->FindElementValueAsNumber("rate"); if (rate <= 0 || rate > 1.0) { - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::WARN); + FGLogging log(LogLevel::WARN); log << "FGLinearActuator::Run " << InputNodes[0]->GetNameWithSign() << " parameter is forced from " << fixed << rate << " value to 0.5 value\n"; @@ -246,7 +246,7 @@ void FGLinearActuator::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " INPUT: " << InputNodes[0]->GetNameWithSign() << fixed << "\n"; log << " inputMem: " << inputMem << "\n"; log << " bias: " << bias << "\n"; @@ -265,7 +265,7 @@ void FGLinearActuator::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGLinearActuator\n"; if (from == 1) log << "Destroyed: FGLinearActuator\n"; } diff --git a/src/models/flight_control/FGMagnetometer.cpp b/src/models/flight_control/FGMagnetometer.cpp index b7b271ab8..131452961 100644 --- a/src/models/flight_control/FGMagnetometer.cpp +++ b/src/models/flight_control/FGMagnetometer.cpp @@ -53,7 +53,7 @@ CLASS IMPLEMENTATION FGMagnetometer::FGMagnetometer(FGFCS* fcs, Element* element) : FGSensor(fcs, element), - FGSensorOrientation(element, fcs->GetExec()->GetLogger()), + FGSensorOrientation(element), counter(0), INERTIAL_UPDATE_RATE(1000) { Propagate = fcs->GetExec()->GetPropagate(); @@ -64,7 +64,7 @@ FGMagnetometer::FGMagnetometer(FGFCS* fcs, Element* element) if (location_element) vLocation = location_element->FindElementTripletConvertTo("IN"); else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "No location given for magnetometer.\n"; throw err; } @@ -174,13 +174,13 @@ 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); + FGLogging log(LogLevel::DEBUG); if (from == 0) { // Constructor log << " Axis: " << ax[axis] << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGMagnetometer\n"; if (from == 1) log << "Destroyed: FGMagnetometer\n"; } diff --git a/src/models/flight_control/FGPID.cpp b/src/models/flight_control/FGPID.cpp index 1ce756371..7aa4dfa25 100644 --- a/src/models/flight_control/FGPID.cpp +++ b/src/models/flight_control/FGPID.cpp @@ -235,7 +235,7 @@ 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); + FGLogging log(LogLevel::DEBUG); if (from == 0) { // Constructor log << " INPUT: " << InputNodes[0]->GetNameWithSign() << "\n"; @@ -244,7 +244,7 @@ void FGPID::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGPID\n"; if (from == 1) log << "Destroyed: FGPID\n"; } diff --git a/src/models/flight_control/FGSensor.cpp b/src/models/flight_control/FGSensor.cpp index 9d8d14cab..8615ffe9c 100644 --- a/src/models/flight_control/FGSensor.cpp +++ b/src/models/flight_control/FGSensor.cpp @@ -103,7 +103,7 @@ FGSensor::FGSensor(FGFCS* fcs, Element* element) NoiseType = eAbsolute; } else { NoiseType = ePercent; - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Unknown noise type in sensor: " << Name << "\n defaulting to PERCENT.\n"; } @@ -114,7 +114,7 @@ FGSensor::FGSensor(FGFCS* fcs, Element* element) DistributionType = eGaussian; } else { DistributionType = eUniform; - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "Unknown random distribution type in sensor: " << Name << "\n defaulting to UNIFORM.\n"; } @@ -272,7 +272,7 @@ void FGSensor::bind(Element* el, FGPropertyManager* PropertyManager) string qprop = "fcs/" + PropertyManager->mkPropertyName(quant_property, true); SGPropertyNode* node = PropertyManager->GetNode(qprop, true); if (node->isTied()) { - XMLLogException err(fcs->GetExec()->GetLogger(), el); + XMLLogException err(el); err << "Property " << tmp << " has already been successfully bound (late).\n"; throw err; } @@ -324,7 +324,7 @@ 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); + FGLogging log(LogLevel::DEBUG); if (from == 0) { // Constructor if (!InputNodes.empty()) log << " INPUT: " << InputNodes[0]->GetNameWithSign() << fixed @@ -363,7 +363,7 @@ void FGSensor::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGSensor\n"; if (from == 1) log << "Destroyed: FGSensor\n"; } diff --git a/src/models/flight_control/FGSensorOrientation.h b/src/models/flight_control/FGSensorOrientation.h index 21f387743..fa50bc203 100644 --- a/src/models/flight_control/FGSensorOrientation.h +++ b/src/models/flight_control/FGSensorOrientation.h @@ -70,7 +70,7 @@ CLASS DECLARATION class FGSensorOrientation : public FGJSBBase { public: - FGSensorOrientation(Element* element, std::shared_ptr logger) + FGSensorOrientation(Element* element) { Element* orient_element = element->FindElement("orientation"); if (orient_element) vOrient = orient_element->FindElementTripletConvertTo("RAD"); @@ -90,7 +90,7 @@ class FGSensorOrientation : public FGJSBBase } if (axis == 0) { - FGXMLLogging log(logger, element, LogLevel::WARN); + FGXMLLogging log(element, LogLevel::WARN); log << " Incorrect/no axis specified for this sensor; assuming X axis\n"; axis = 1; } diff --git a/src/models/flight_control/FGSummer.cpp b/src/models/flight_control/FGSummer.cpp index 84f6617d8..c1c5c2d18 100644 --- a/src/models/flight_control/FGSummer.cpp +++ b/src/models/flight_control/FGSummer.cpp @@ -109,7 +109,7 @@ 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); + FGLogging log(LogLevel::DEBUG); if (from == 0) { // Constructor log << " INPUTS: " << fixed << "\n"; for (auto node: InputNodes) @@ -120,7 +120,7 @@ void FGSummer::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGSummer\n"; if (from == 1) log << "Destroyed: FGSummer\n"; } diff --git a/src/models/flight_control/FGSwitch.cpp b/src/models/flight_control/FGSwitch.cpp index d91eb666d..b5b700ef9 100644 --- a/src/models/flight_control/FGSwitch.cpp +++ b/src/models/flight_control/FGSwitch.cpp @@ -99,7 +99,7 @@ FGSwitch::FGSwitch(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) } tests.push_back(current_test.release()); } catch (const BaseException& e) { - FGXMLLogging log(fcs->GetExec()->GetLogger(), test_element, LogLevel::ERROR); + FGXMLLogging log(test_element, LogLevel::ERROR); log << e.what() << "\n" << " Default value IGNORED.\n"; } @@ -114,7 +114,7 @@ FGSwitch::FGSwitch(FGFCS* fcs, Element* element) : FGFCSComponent(fcs, element) current_test->setTestValue(value, Name, PropertyManager, test_element); tests.push_back(current_test.release()); } catch (const BaseException& e) { - FGXMLLogging log(fcs->GetExec()->GetLogger(), test_element, LogLevel::ERROR); + FGXMLLogging log(test_element, LogLevel::ERROR); log << e.what() << "\n" << " Test IGNORED.\n"; } @@ -206,7 +206,7 @@ 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); + FGLogging log(LogLevel::DEBUG); unsigned int i = 0; for (auto test: tests) { if (test->Default) { @@ -224,7 +224,7 @@ void FGSwitch::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGSwitch\n"; if (from == 1) log << "Destroyed: FGSwitch\n"; } diff --git a/src/models/flight_control/FGWaypoint.cpp b/src/models/flight_control/FGWaypoint.cpp index fa020eeed..9fdc4ead9 100644 --- a/src/models/flight_control/FGWaypoint.cpp +++ b/src/models/flight_control/FGWaypoint.cpp @@ -78,7 +78,7 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) } } } else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Target latitude is required for waypoint component: " << Name << "\n"; throw err; } @@ -92,7 +92,7 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) } } } else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Target longitude is required for waypoint component: " << Name << "\n"; throw err; } @@ -106,7 +106,7 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) } } } else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Source latitude is required for waypoint component: " << Name << "\n"; throw err; } @@ -120,7 +120,7 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) } } } else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Source longitude is required for waypoint component: " << Name << "\n"; throw err; } @@ -131,7 +131,7 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) if (unit == "DEG") eUnit = eDeg; else if (unit == "RAD") eUnit = eRad; else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Unknown unit " << unit << " in HEADING waypoint component, " << "\n"; throw err; } @@ -143,7 +143,7 @@ FGWaypoint::FGWaypoint(FGFCS* fcs, Element* element) if (unit == "FT") eUnit = eFeet; else if (unit == "M") eUnit = eMeters; else { - XMLLogException err(fcs->GetExec()->GetLogger(), element); + XMLLogException err(element); err << "Unknown unit " << unit << " in DISTANCE waypoint component, " << Name << "\n"; throw err; @@ -175,7 +175,7 @@ bool FGWaypoint::Run(void ) source.SetPositionGeodetic(source_longitude_rad, source_latitude_rad, 0.0); if (fabs(target_latitude_rad) > M_PI/2.0) { - LogException err(fcs->GetExec()->GetLogger()); + LogException err; err << "\nTarget latitude in waypoint \"" << Name << "\" must be less than or equal to 90 degrees.\n" << "(is longitude being mistakenly supplied?)\n\n"; @@ -183,7 +183,7 @@ bool FGWaypoint::Run(void ) } if (fabs(source_latitude_rad) > M_PI/2.0) { - LogException err(fcs->GetExec()->GetLogger()); + LogException err; err << "\nSource latitude in waypoint \"" << Name << "\" must be less than or equal to 90 degrees.\n" << "(is longitude being mistakenly supplied?)\n\n"; @@ -241,7 +241,7 @@ void FGWaypoint::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fcs->GetExec()->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGWaypoint\n"; if (from == 1) log << "Destroyed: FGWaypoint\n"; } diff --git a/src/models/propulsion/FGForce.cpp b/src/models/propulsion/FGForce.cpp index 485ad29cc..1bd139e84 100644 --- a/src/models/propulsion/FGForce.cpp +++ b/src/models/propulsion/FGForce.cpp @@ -109,7 +109,7 @@ const FGMatrix33& FGForce::Transform(void) const return mT; default: { - LogException err(fdmex->GetLogger()); + LogException err; err << "Unrecognized tranform requested from FGForce::Transform()\n"; throw err; } @@ -185,7 +185,7 @@ void FGForce::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGForce\n"; if (from == 1) log << "Destroyed: FGForce\n"; } diff --git a/src/models/propulsion/FGNozzle.cpp b/src/models/propulsion/FGNozzle.cpp index 626cefa61..11e6aa65a 100644 --- a/src/models/propulsion/FGNozzle.cpp +++ b/src/models/propulsion/FGNozzle.cpp @@ -55,7 +55,7 @@ FGNozzle::FGNozzle(FGFDMExec* FDMExec, Element* nozzle_element, int num) if (nozzle_element->FindElement("area")) Area = nozzle_element->FindElementValueAsNumberConvertTo("area", "FT2"); else { - XMLLogException err(fdmex->GetLogger(), nozzle_element); + XMLLogException err(nozzle_element); err << "Fatal Error: Nozzle exit area must be given in nozzle config file.\n"; throw err; } @@ -131,13 +131,13 @@ void FGNozzle::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << " Nozzle Name: " << Name << "\n"; log << " Nozzle Exit Area = " << Area << "\n"; } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGNozzle\n"; if (from == 1) log << "Destroyed: FGNozzle\n"; } diff --git a/src/models/propulsion/FGPropeller.cpp b/src/models/propulsion/FGPropeller.cpp index 3448416a2..83c96c503 100644 --- a/src/models/propulsion/FGPropeller.cpp +++ b/src/models/propulsion/FGPropeller.cpp @@ -107,17 +107,17 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num) } else if (name == "CP_MACH") { CpMach = new FGTable(PropertyManager, table_element); } else { - FGXMLLogging log(fdmex->GetLogger(), table_element, LogLevel::ERROR); + FGXMLLogging log(table_element, LogLevel::ERROR); log << "Unknown table type: " << name << " in propeller definition.\n"; } } catch (BaseException& e) { - XMLLogException err(fdmex->GetLogger(), table_element); + XMLLogException err(table_element); err << "Error loading propeller table:" << name << ". " << e.what() << "\n"; throw err; } } if( (cPower == nullptr) || (cThrust == nullptr)){ - XMLLogException err(fdmex->GetLogger(), prop_element); + XMLLogException err(prop_element); err << "Propeller configuration must contain C_THRUST and C_POWER tables!\n"; throw err; } @@ -132,7 +132,7 @@ FGPropeller::FGPropeller(FGFDMExec* exec, Element* prop_element, int num) P_Factor = local_element->GetDataAsNumber(); } if (P_Factor < 0) { - XMLLogException err(fdmex->GetLogger(), local_element); + XMLLogException err(local_element); err << "P-Factor value in propeller configuration file must be greater than zero\n"; throw err; } @@ -444,7 +444,7 @@ void FGPropeller::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Propeller Name: " << Name << "\n"; log << " IXX = " << Ixx << "\n"; log << " Diameter = " << Diameter << " ft." << "\n"; @@ -457,7 +457,7 @@ void FGPropeller::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGPropeller\n"; if (from == 1) log << "Destroyed: FGPropeller\n"; } diff --git a/src/models/propulsion/FGRotor.cpp b/src/models/propulsion/FGRotor.cpp index 9cf6cbaa5..005510150 100644 --- a/src/models/propulsion/FGRotor.cpp +++ b/src/models/propulsion/FGRotor.cpp @@ -120,7 +120,7 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) if (thruster_element) { location = thruster_element->FindElementTripletConvertTo("IN"); } else { - FGXMLLogging log(exec->GetLogger(), rotor_element, LogLevel::ERROR); + FGXMLLogging log(rotor_element, LogLevel::ERROR); log << "No thruster location found.\n"; } @@ -128,7 +128,7 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) if (thruster_element) { orientation = thruster_element->FindElementTripletConvertTo("RAD"); } else { - FGXMLLogging log(exec->GetLogger(), rotor_element, LogLevel::ERROR); + FGXMLLogging log(rotor_element, LogLevel::ERROR); log << "No thruster orientation found.\n"; } @@ -147,7 +147,7 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) } else if (cm == "TANDEM") { ControlMap = eTandemCtrl; } else { - FGXMLLogging log(exec->GetLogger(), controlmap_el, LogLevel::ERROR); + FGXMLLogging log(controlmap_el, LogLevel::ERROR); log << "# found unknown controlmap: '" << cm << "' using main rotor config.\n"; } } @@ -170,7 +170,7 @@ FGRotor::FGRotor(FGFDMExec *exec, Element* rotor_element, int num) } } if (RPMdefinition != rdef) { - FGXMLLogging log(exec->GetLogger(), extrpm_el, LogLevel::ERROR); + FGXMLLogging log(extrpm_el, LogLevel::ERROR); log << "# discarded given RPM source (" << rdef << ") and switched to external control (-1).\n"; } @@ -251,7 +251,7 @@ double FGRotor::ConfigValueConv( Element* el, const string& ename, double defaul } } else { if (tell) { - FGXMLLogging log(fdmex->GetLogger(), el, LogLevel::ERROR); + FGXMLLogging log(el, LogLevel::ERROR); log << pname << ": missing element '" << ename << "' using estimated value: " << default_val << "\n"; } @@ -774,13 +774,13 @@ bool FGRotor::bindmodel(FGPropertyManager* PropertyManager) property_name = ipn + "/rotor-rpm"; ExtRPMsource = PropertyManager->GetNode(property_name, false); if (! ExtRPMsource) { - FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); + FGLogging log(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 { - FGLogging log(fdmex->GetLogger(), LogLevel::ERROR); + FGLogging log(LogLevel::ERROR); log << "# Engine number " << EngineNum; log << ", given ExternalRPM value '" << RPMdefinition << "' unhandled.\n"; } @@ -842,7 +842,7 @@ void FGRotor::Debug(int from) if (debug_lvl & 1) { // Standard console startup message output if (from == 0) { // Constructor - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); log << "\n Rotor Name: " << Name << "\n"; log << " Diameter = " << 2.0 * Radius << " ft." << "\n"; log << " Number of Blades = " << BladeNum << "\n"; @@ -885,7 +885,7 @@ void FGRotor::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGRotor\n"; if (from == 1) log << "Destroyed: FGRotor\n"; } diff --git a/src/models/propulsion/FGThruster.cpp b/src/models/propulsion/FGThruster.cpp index 74bfb8976..3b71a209a 100644 --- a/src/models/propulsion/FGThruster.cpp +++ b/src/models/propulsion/FGThruster.cpp @@ -71,7 +71,7 @@ FGThruster::FGThruster(FGFDMExec *FDMExec, Element *el, int num ): FGForce(FDMEx element = thruster_element->FindElement("location"); if (element) location = element->FindElementTripletConvertTo("IN"); else { - FGXMLLogging log(FDMExec->GetLogger(), thruster_element, LogLevel::ERROR); + FGXMLLogging log(thruster_element, LogLevel::ERROR); log << LogFormat::RED << " No thruster location found." << LogFormat::RESET << "\n"; } @@ -198,7 +198,7 @@ void FGThruster::Debug(int from) } } if (debug_lvl & 2 ) { // Instantiation/Destruction notification - FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG); + FGLogging log(LogLevel::DEBUG); if (from == 0) log << "Instantiated: FGThruster\n"; if (from == 1) log << "Destroyed: FGThruster\n"; } diff --git a/tests/unit_tests/FGAuxiliaryTest.h b/tests/unit_tests/FGAuxiliaryTest.h index 08a6f1109..ae7a80905 100644 --- a/tests/unit_tests/FGAuxiliaryTest.h +++ b/tests/unit_tests/FGAuxiliaryTest.h @@ -35,6 +35,13 @@ class FGAuxiliaryTest : public CxxTest::TestSuite fdmex.GetPropertyManager()->Unbind(aux); } + ~FGAuxiliaryTest() { + // Avoid constructing `FGLogging` instances in a static instance of + // FGAuxiliaryTest. This is due to the destruction of thread local storage + // *before* the destruction of static globals. + JSBSim::FGJSBBase::debug_lvl = 0; + } + void testPitotTotalPressure() { auto aux = FGAuxiliary(&fdmex); aux.in.vLocation = fdmex.GetAuxiliary()->in.vLocation; diff --git a/tests/unit_tests/FGLogTest.h b/tests/unit_tests/FGLogTest.h index 1e7c1ea0c..e5ebce65f 100644 --- a/tests/unit_tests/FGLogTest.h +++ b/tests/unit_tests/FGLogTest.h @@ -32,22 +32,27 @@ class DummyLogger : public JSBSim::FGLogger class FGLogTest : public CxxTest::TestSuite { public: +std::shared_ptr logger; + +void setUp() { + logger = std::make_shared(); + JSBSim::SetLogger(logger); +} + void testConstructor() { - auto logger = std::make_shared(); TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); TS_ASSERT_EQUALS(logger->GetLogLevel(), JSBSim::LogLevel::BULK); - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); TS_ASSERT_EQUALS(logger->GetLogLevel(), JSBSim::LogLevel::INFO); } void testDestructor() { - auto logger = std::make_shared(); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); TS_ASSERT_EQUALS(logger->GetLogLevel(), JSBSim::LogLevel::INFO); @@ -58,10 +63,9 @@ void testDestructor() { } void testCharMessage() { - auto logger = std::make_shared(); const char* message = "Hello, World!"; { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log <flushed); TS_ASSERT(logger->buffer.empty()); @@ -73,10 +77,9 @@ void testCharMessage() { } void testStringMessage() { - auto logger = std::make_shared(); std::string message = "Hello, World!"; { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << message; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -88,11 +91,10 @@ void testStringMessage() { } void testConcatenatedMessages() { - auto logger = std::make_shared(); std::string message1 = "Hello"; std::string message2 = "World!"; { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << message1 << " " << message2; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -104,9 +106,8 @@ void testConcatenatedMessages() { } void testEndl() { - auto logger = std::make_shared(); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << "Hello" << std::endl << "World!"; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -118,9 +119,8 @@ void testEndl() { } void testNumbers() { - auto logger = std::make_shared(); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << 1 << 2.1 << -3.4f; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -132,9 +132,8 @@ void testNumbers() { } void testSetPrecision() { - auto logger = std::make_shared(); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << std::setprecision(3) << 1.23456789; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -146,9 +145,8 @@ void testSetPrecision() { } void testSetWidthRight() { - auto logger = std::make_shared(); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << std::setw(5) << 123; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -160,9 +158,8 @@ void testSetWidthRight() { } void testSetWidthLeft() { - auto logger = std::make_shared(); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << std::left << std::setw(5) << 123; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -174,10 +171,9 @@ void testSetWidthLeft() { } void testPath() { - auto logger = std::make_shared(); SGPath path("path/to"); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << (path/"file"); TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -189,10 +185,9 @@ void testPath() { } void testColumnVector3() { - auto logger = std::make_shared(); JSBSim::FGColumnVector3 vec(1, 2, 3); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << vec; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -204,9 +199,8 @@ void testColumnVector3() { } void testFormatOnly() { - auto logger = std::make_shared(); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); log << JSBSim::LogFormat::NORMAL; @@ -220,9 +214,8 @@ void testFormatOnly() { } void testClosingFormat() { - auto logger = std::make_shared(); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << "Hello,"; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -238,9 +231,8 @@ void testClosingFormat() { } void testMidFormat() { - auto logger = std::make_shared(); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << "Hello,"; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -260,12 +252,11 @@ void testMidFormat() { } void testXMLLogging() { - auto logger = std::make_shared(); JSBSim::Element el("element"); el.SetFileName("file.xml"); el.SetLineNumber(42); { - JSBSim::FGXMLLogging log(logger, &el, JSBSim::LogLevel::DEBUG); + JSBSim::FGXMLLogging log(&el, JSBSim::LogLevel::DEBUG); TS_ASSERT_EQUALS(logger->buffer, "file.xml:42"); TS_ASSERT(!logger->flushed); TS_ASSERT_EQUALS(logger->GetLogLevel(), JSBSim::LogLevel::DEBUG); @@ -279,13 +270,19 @@ void testXMLLogging() { class FGLogConsoleTest : public CxxTest::TestSuite { public: +std::shared_ptr logger; + +void setUp() { + logger = std::make_shared(); + JSBSim::SetLogger(logger); +} + void testNormalMessage() { - auto logger = std::make_shared(); std::ostringstream buffer; auto cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(buffer.rdbuf()); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::DEBUG); + JSBSim::FGLogging log(JSBSim::LogLevel::DEBUG); log << "Hello, World!"; } std::cout.rdbuf(cout_buffer); @@ -293,12 +290,11 @@ void testNormalMessage() { } void testErrorMessage() { - auto logger = std::make_shared(); std::ostringstream buffer; auto cerr_buffer = std::cerr.rdbuf(); std::cerr.rdbuf(buffer.rdbuf()); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::ERROR); + JSBSim::FGLogging log(JSBSim::LogLevel::ERROR); log << "Hello, World!"; } std::cerr.rdbuf(cerr_buffer); @@ -306,7 +302,6 @@ void testErrorMessage() { } void testXMLLogging() { - auto logger = std::make_shared(); std::ostringstream buffer; auto cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(buffer.rdbuf()); @@ -314,24 +309,23 @@ void testXMLLogging() { el.SetFileName("name.xml"); el.SetLineNumber(42); { - JSBSim::FGXMLLogging log(logger, &el, JSBSim::LogLevel::DEBUG); + JSBSim::FGXMLLogging log(&el, JSBSim::LogLevel::DEBUG); } std::cout.rdbuf(cout_buffer); TS_ASSERT_EQUALS(buffer.str(), "\nIn file name.xml: line 42\n"); } void testMinLevel() { - auto logger = std::make_shared(); logger->SetMinLevel(JSBSim::LogLevel::DEBUG); std::ostringstream buffer; auto cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(buffer.rdbuf()); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::BULK); + JSBSim::FGLogging log(JSBSim::LogLevel::BULK); log << "BULK"; } { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << "INFO"; } std::cout.rdbuf(cout_buffer); @@ -339,12 +333,11 @@ void testMinLevel() { } void testRedFormat() { - auto logger = std::make_shared(); std::ostringstream buffer; auto cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(buffer.rdbuf()); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << JSBSim::LogFormat::RED; log << "Hello, World!"; log << JSBSim::LogFormat::RESET; @@ -354,12 +347,11 @@ void testRedFormat() { } void testCyanFormat() { - auto logger = std::make_shared(); std::ostringstream buffer; auto cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(buffer.rdbuf()); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << JSBSim::LogFormat::BLUE; log << "Hello, World!"; log << JSBSim::LogFormat::RESET; @@ -369,12 +361,11 @@ void testCyanFormat() { } void testBoldFormat() { - auto logger = std::make_shared(); std::ostringstream buffer; auto cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(buffer.rdbuf()); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << JSBSim::LogFormat::BOLD; log << "Hello, World!"; log << JSBSim::LogFormat::RESET; @@ -384,12 +375,11 @@ void testBoldFormat() { } void testNormalFormat() { - auto logger = std::make_shared(); std::ostringstream buffer; auto cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(buffer.rdbuf()); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << JSBSim::LogFormat::NORMAL; log << "Hello, World!"; log << JSBSim::LogFormat::RESET; @@ -399,12 +389,11 @@ void testNormalFormat() { } void testUnderlineFormat() { - auto logger = std::make_shared(); std::ostringstream buffer; auto cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(buffer.rdbuf()); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << JSBSim::LogFormat::UNDERLINE_ON; log << "Hello, World!"; log << JSBSim::LogFormat::UNDERLINE_OFF; @@ -414,12 +403,11 @@ void testUnderlineFormat() { } void testDefaultFormat() { - auto logger = std::make_shared(); std::ostringstream buffer; auto cout_buffer = std::cout.rdbuf(); std::cout.rdbuf(buffer.rdbuf()); { - JSBSim::FGLogging log(logger, JSBSim::LogLevel::INFO); + JSBSim::FGLogging log(JSBSim::LogLevel::INFO); log << JSBSim::LogFormat::DEFAULT; log << "Hello, World!"; log << JSBSim::LogFormat::RESET; @@ -432,18 +420,23 @@ void testDefaultFormat() { class LogExceptionTest : public CxxTest::TestSuite { public: +std::shared_ptr logger; + +void setUp() { + logger = std::make_shared(); + JSBSim::SetLogger(logger); +} + void testConstructor() { - auto logger = std::make_shared(); - JSBSim::LogException logException(logger); + JSBSim::LogException logException; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); TS_ASSERT_EQUALS(logger->GetLogLevel(), JSBSim::LogLevel::BULK); } void testDestructor() { - auto logger = std::make_shared(); { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); TS_ASSERT_EQUALS(logger->GetLogLevel(), JSBSim::LogLevel::BULK); @@ -454,9 +447,8 @@ void testDestructor() { } void testThrow() { - auto logger = std::make_shared(); try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; throw logException; } catch (JSBSim::BaseException&) { TS_ASSERT(!logger->flushed); @@ -469,9 +461,8 @@ void testThrow() { } void testThrowEmptyMessage() { - auto logger = std::make_shared(); try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; logException << ""; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -488,10 +479,9 @@ void testThrowEmptyMessage() { } void testThrowWithMessage() { - auto logger = std::make_shared(); std::string message = "Hello, World!"; try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; logException << message; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -508,11 +498,10 @@ void testThrowWithMessage() { } void testThrowConcatenatedMessages1() { - auto logger = std::make_shared(); std::string message1 = "Hello"; std::string message2 = ", World!"; try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; logException << message1 << message2; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -529,11 +518,10 @@ void testThrowConcatenatedMessages1() { } void testThrowConcatenatedMessages2() { - auto logger = std::make_shared(); std::string message1 = "Hello"; std::string message2 = ", World!"; try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; logException << message1; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -554,10 +542,9 @@ void testThrowConcatenatedMessages2() { } void testThrowFormattedMessages1() { - auto logger = std::make_shared(); std::string message = "Hello, World!"; try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; logException << JSBSim::LogFormat::NORMAL << message; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -574,10 +561,9 @@ void testThrowFormattedMessages1() { } void testThrowFormattedMessages2() { - auto logger = std::make_shared(); std::string message = "Hello, World!"; try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; logException << JSBSim::LogFormat::NORMAL; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -598,11 +584,10 @@ void testThrowFormattedMessages2() { } void testThrowFormattedMessages3() { - auto logger = std::make_shared(); std::string message1 = "Hello"; std::string message2 = ", World!"; try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; logException << message1 << JSBSim::LogFormat::NORMAL << message2; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -620,11 +605,10 @@ void testThrowFormattedMessages3() { } void testThrowAndAppendMessage() { - auto logger = std::make_shared(); std::string message1 = "Hello"; std::string message2 = ", World!"; try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; logException << message1; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -648,24 +632,29 @@ void testThrowAndAppendMessage() { class testXMLLogException : public CxxTest::TestSuite { public: +std::shared_ptr logger; + +void setUp() { + logger = std::make_shared(); + JSBSim::SetLogger(logger); +} + void testConstructor() { - auto logger = std::make_shared(); JSBSim::Element el("element"); el.SetFileName("file.xml"); el.SetLineNumber(42); - JSBSim::XMLLogException logException(logger, &el); + JSBSim::XMLLogException logException(&el); TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); TS_ASSERT_EQUALS(logger->GetLogLevel(), JSBSim::LogLevel::BULK); } void testThrow() { - auto logger = std::make_shared(); JSBSim::Element el("element"); el.SetFileName("file.xml"); el.SetLineNumber(42); try { - JSBSim::XMLLogException logException(logger, &el); + JSBSim::XMLLogException logException(&el); throw logException; } catch (JSBSim::BaseException&) { TS_ASSERT(!logger->flushed); @@ -678,12 +667,11 @@ void testThrow() { } void testEmptyMessage() { - auto logger = std::make_shared(); JSBSim::Element el("element"); el.SetFileName("file.xml"); el.SetLineNumber(42); try { - JSBSim::XMLLogException logException(logger, &el); + JSBSim::XMLLogException logException(&el); logException << ""; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -700,13 +688,12 @@ void testEmptyMessage() { } void testWithMessage() { - auto logger = std::make_shared(); JSBSim::Element el("element"); el.SetFileName("file.xml"); el.SetLineNumber(42); std::string message = "Hello, World!"; try { - JSBSim::XMLLogException logException(logger, &el); + JSBSim::XMLLogException logException(&el); logException << message; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); @@ -723,13 +710,12 @@ void testWithMessage() { } void testPromoteLogException() { - auto logger = std::make_shared(); JSBSim::Element el("element"); el.SetFileName("file.xml"); el.SetLineNumber(42); try { try { - JSBSim::LogException logException(logger); + JSBSim::LogException logException; logException << "Hello, World!"; TS_ASSERT(!logger->flushed); TS_ASSERT(logger->buffer.empty()); diff --git a/tests/unit_tests/FGMSISTest.h b/tests/unit_tests/FGMSISTest.h index 170d09814..40a2c41d8 100644 --- a/tests/unit_tests/FGMSISTest.h +++ b/tests/unit_tests/FGMSISTest.h @@ -56,6 +56,13 @@ class FGMSISTest : public CxxTest::TestSuite, FGJSBBase std::vector MSIS_alt, MSIS_glat, MSIS_glon, MSIS_f107a, MSIS_f107, MSIS_ap, MSIS_T, MSIS_rho, MSIS_mair; + ~FGMSISTest() { + // Avoid constructing `FGLogging` instances in a static instance of + // FGMSISTest. This is due to the destruction of thread local storage + // *before* the destruction of static globals. + JSBSim::FGJSBBase::debug_lvl = 0; + } + FGMSISTest() { std_atm = fdmex.GetAtmosphere(); fdmex.GetPropertyManager()->Unbind(std_atm);