Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging redesign - part 4 #1176

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/models/FGExternalReactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/

#include "FGFDMExec.h"
#include "FGExternalForce.h"
#include "FGExternalReactions.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGLog.h"

using namespace std;

Expand Down Expand Up @@ -173,12 +175,14 @@
if (from == 0) { // Constructor - loading and initialization
}
if (from == 2) { // Loading
cout << endl << " External Reactions: " << endl;
FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG);
log << "\n External Reactions: \n";

Check warning on line 179 in src/models/FGExternalReactions.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGExternalReactions.cpp#L178-L179

Added lines #L178 - L179 were not covered by tests
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGExternalReactions" << endl;
if (from == 1) cout << "Destroyed: FGExternalReactions" << endl;
FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: FGExternalReactions\n";
if (from == 1) log << "Destroyed: FGExternalReactions\n";

Check warning on line 185 in src/models/FGExternalReactions.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGExternalReactions.cpp#L183-L185

Added lines #L183 - L185 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
Expand Down
141 changes: 72 additions & 69 deletions src/models/FGGasCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@
#include "models/FGMassBalance.h"
#include "FGGasCell.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGLog.h"

using std::cerr;
using std::endl;
using std::cout;
using std::string;
using std::max;

Expand Down Expand Up @@ -86,9 +84,9 @@
if (element) {
vXYZ = element->FindElementTripletConvertTo("IN");
} else {
const string s("Fatal Error: No location found for this gas cell.");
cerr << el->ReadFrom() << endl << s << endl;
throw BaseException(s);
FGXMLLogging log(exec->GetLogger(), el, LogLevel::FATAL);
log << "\nFatal Error: No location found for this gas cell.\n";
throw BaseException(log.str());

Check warning on line 89 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L87-L89

Added lines #L87 - L89 were not covered by tests
}
if ((el->FindElement("x_radius") || el->FindElement("x_width")) &&
(el->FindElement("y_radius") || el->FindElement("y_width")) &&
Expand Down Expand Up @@ -126,7 +124,8 @@
// Cylindrical volume.
MaxVolume = M_PI * Yradius * Zradius * Xwidth;
} else {
cerr << "Warning: Unsupported gas cell shape." << endl;
FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN);
log << "Unsupported gas cell shape.\n";

Check warning on line 128 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L127-L128

Added lines #L127 - L128 were not covered by tests
MaxVolume =
(4.0 * M_PI * Xradius * Yradius * Zradius / 3.0 +
M_PI * Yradius * Zradius * Xwidth +
Expand All @@ -138,9 +137,9 @@
Xwidth * Ywidth * Zwidth);
}
} else {
const string s("Fatal Error: Gas cell shape must be given.");
cerr << el->ReadFrom() << endl << s << endl;
throw BaseException(s);
FGXMLLogging log(exec->GetLogger(), el, LogLevel::FATAL);
log << "\nGas cell shape must be given.\n";
throw BaseException(log.str());

Check warning on line 142 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L140-L142

Added lines #L140 - L142 were not covered by tests
}
if (el->FindElement("max_overpressure")) {
MaxOverpressure = el->FindElementValueAsNumberConvertTo("max_overpressure",
Expand All @@ -151,7 +150,8 @@
if (0 <= Fullness) {
Volume = Fullness * MaxVolume;
} else {
cerr << "Warning: Invalid initial gas cell fullness value." << endl;
FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN);
log << "Invalid initial gas cell fullness value.\n";

Check warning on line 154 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L153-L154

Added lines #L153 - L154 were not covered by tests
}
}
if (el->FindElement("valve_coefficient")) {
Expand Down Expand Up @@ -448,38 +448,38 @@

if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
cout << " Gas cell holds " << Contents << " mol " <<
type << endl;
cout << " Cell location (X, Y, Z) (in.): " << vXYZ(eX) << ", " <<
vXYZ(eY) << ", " << vXYZ(eZ) << endl;
cout << " Maximum volume: " << MaxVolume << " ft3" << endl;
cout << " Relief valve release pressure: " << MaxOverpressure <<
" lbs/ft2" << endl;
cout << " Manual valve coefficient: " << ValveCoefficient <<
" ft4*sec/slug" << endl;
cout << " Initial temperature: " << Temperature << " Rankine" <<
endl;
cout << " Initial pressure: " << Pressure << " lbs/ft2" << endl;
cout << " Initial volume: " << Volume << " ft3" << endl;
cout << " Initial mass: " << GetMass() << " slug mass" << endl;
cout << " Initial weight: " << GetMass()*slugtolb << " lbs force" <<
endl;
cout << " Heat transfer: " << endl;
FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG);
log << " Gas cell holds " << fixed << Contents << " mol " << type << "\n";
log << " Cell location (X, Y, Z) (in.): " << vXYZ(eX) << ", "
<< vXYZ(eY) << ", " << vXYZ(eZ) << "\n";
log << " Maximum volume: " << MaxVolume << " ft3\n";
log << " Relief valve release pressure: " << MaxOverpressure
<< " lbs/ft2\n";
log << " Manual valve coefficient: " << ValveCoefficient
<< " ft4*sec/slug\n";
log << " Initial temperature: " << Temperature << " Rankine\n";
log << " Initial pressure: " << Pressure << " lbs/ft2\n";
log << " Initial volume: " << Volume << " ft3\n";
log << " Initial mass: " << GetMass() << " slug mass\n";
log << " Initial weight: " << GetMass()*slugtolb << " lbs force\n";
log << " Heat transfer: \n";

Check warning on line 465 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L451-L465

Added lines #L451 - L465 were not covered by tests
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGGasCell" << endl;
if (from == 1) cout << "Destroyed: FGGasCell" << endl;
FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: FGGasCell\n";
if (from == 1) log << "Destroyed: FGGasCell\n";

Check warning on line 471 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L469-L471

Added lines #L469 - L471 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
if (debug_lvl & 8 ) { // Runtime state variables
cout << " " << type << " cell holds " << Contents << " mol " << endl;
cout << " Temperature: " << Temperature << " Rankine" << endl;
cout << " Pressure: " << Pressure << " lbs/ft2" << endl;
cout << " Volume: " << Volume << " ft3" << endl;
cout << " Mass: " << GetMass() << " slug mass" << endl;
cout << " Weight: " << GetMass()*slugtolb << " lbs force" << endl;
FGLogging log(fdmex->GetLogger(), LogLevel::DEBUG);
log << " " << type << " cell holds " << fixed << Contents << " mol\n";
log << " Temperature: " << Temperature << " Rankine\n";
log << " Pressure: " << Pressure << " lbs/ft2\n";
log << " Volume: " << Volume << " ft3\n";
log << " Mass: " << GetMass() << " slug mass\n";
log << " Weight: " << GetMass()*slugtolb << " lbs force\n";

Check warning on line 482 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L476-L482

Added lines #L476 - L482 were not covered by tests
}
if (debug_lvl & 16) { // Sanity checking
}
Expand Down Expand Up @@ -519,9 +519,9 @@
if (element) {
vXYZ = element->FindElementTripletConvertTo("IN");
} else {
const string s("Fatal Error: No location found for this ballonet.");
cerr << el->ReadFrom() << endl << s << endl;
throw BaseException(s);
FGXMLLogging log(exec->GetLogger(), el, LogLevel::FATAL);
log << "\nFatal Error: No location found for this ballonet.\n";
throw BaseException(log.str());

Check warning on line 524 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L522-L524

Added lines #L522 - L524 were not covered by tests
}
if ((el->FindElement("x_radius") || el->FindElement("x_width")) &&
(el->FindElement("y_radius") || el->FindElement("y_width")) &&
Expand Down Expand Up @@ -559,7 +559,8 @@
// Cylindrical volume.
MaxVolume = M_PI * Yradius * Zradius * Xwidth;
} else {
cerr << "Warning: Unsupported ballonet shape." << endl;
FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN);
log << "Unsupported ballonet shape.\n";

Check warning on line 563 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L562-L563

Added lines #L562 - L563 were not covered by tests
MaxVolume =
(4.0 * M_PI * Xradius * Yradius * Zradius / 3.0 +
M_PI * Yradius * Zradius * Xwidth +
Expand All @@ -571,9 +572,9 @@
Xwidth * Ywidth * Zwidth);
}
} else {
const string s("Fatal Error: Ballonet shape must be given.");
cerr << el->ReadFrom() << endl << s << endl;
throw BaseException(s);
FGXMLLogging log(exec->GetLogger(), el, LogLevel::FATAL);
log << "\nFatal Error: Ballonet shape must be given.\n";
throw BaseException(log.str());

Check warning on line 577 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L575-L577

Added lines #L575 - L577 were not covered by tests
}
if (el->FindElement("max_overpressure")) {
MaxOverpressure = el->FindElementValueAsNumberConvertTo("max_overpressure",
Expand All @@ -584,7 +585,8 @@
if (0 <= Fullness) {
Volume = Fullness * MaxVolume;
} else {
cerr << "Warning: Invalid initial ballonet fullness value." << endl;
FGXMLLogging log(exec->GetLogger(), el, LogLevel::WARN);
log << "Invalid initial ballonet fullness value.\n";

Check warning on line 589 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L588-L589

Added lines #L588 - L589 were not covered by tests
}
}
if (el->FindElement("valve_coefficient")) {
Expand Down Expand Up @@ -798,38 +800,39 @@

if (debug_lvl & 1) { // Standard console startup message output
if (from == 0) { // Constructor
cout << " Ballonet holds " << Contents << " mol air" << endl;
cout << " Location (X, Y, Z) (in.): " << vXYZ(eX) << ", " <<
vXYZ(eY) << ", " << vXYZ(eZ) << endl;
cout << " Maximum volume: " << MaxVolume << " ft3" << endl;
cout << " Relief valve release pressure: " << MaxOverpressure <<
" lbs/ft2" << endl;
cout << " Relief valve coefficient: " << ValveCoefficient <<
" ft4*sec/slug" << endl;
cout << " Initial temperature: " << Temperature << " Rankine" <<
endl;
cout << " Initial pressure: " << Pressure << " lbs/ft2" << endl;
cout << " Initial volume: " << Volume << " ft3" << endl;
cout << " Initial mass: " << GetMass() << " slug mass" << endl;
cout << " Initial weight: " << GetMass()*slugtolb <<
" lbs force" << endl;
cout << " Heat transfer: " << endl;
FGLogging log(MassBalance->GetExec()->GetLogger(), LogLevel::DEBUG);
log << " Ballonet holds " << fixed << Contents << " mol air\n";
log << " Location (X, Y, Z) (in.): " << vXYZ(eX) << ", "
<< vXYZ(eY) << ", " << vXYZ(eZ) << "\n";
log << " Maximum volume: " << MaxVolume << " ft3\n";
log << " Relief valve release pressure: " << MaxOverpressure
<< " lbs/ft2\n";
log << " Relief valve coefficient: " << ValveCoefficient
<< " ft4*sec/slug\n";
log << " Initial temperature: " << Temperature << " Rankine\n";
log << " Initial pressure: " << Pressure << " lbs/ft2\n";
log << " Initial volume: " << Volume << " ft3\n";
log << " Initial mass: " << GetMass() << " slug mass\n";
log << " Initial weight: " << GetMass()*slugtolb
<< " lbs force\n";
log << " Heat transfer: \n";

Check warning on line 818 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L803-L818

Added lines #L803 - L818 were not covered by tests
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGBallonet" << endl;
if (from == 1) cout << "Destroyed: FGBallonet" << endl;
FGLogging log(MassBalance->GetExec()->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: FGBallonet\n";
if (from == 1) log << "Destroyed: FGBallonet\n";

Check warning on line 824 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L822-L824

Added lines #L822 - L824 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
if (debug_lvl & 8 ) { // Runtime state variables
cout << " Ballonet holds " << Contents <<
" mol air" << endl;
cout << " Temperature: " << Temperature << " Rankine" << endl;
cout << " Pressure: " << Pressure << " lbs/ft2" << endl;
cout << " Volume: " << Volume << " ft3" << endl;
cout << " Mass: " << GetMass() << " slug mass" << endl;
cout << " Weight: " << GetMass()*slugtolb << " lbs force" << endl;
FGLogging log(MassBalance->GetExec()->GetLogger(), LogLevel::DEBUG);
log << " Ballonet holds " << fixed << Contents << " mol air\n";
log << " Temperature: " << Temperature << " Rankine\n";
log << " Pressure: " << Pressure << " lbs/ft2\n";
log << " Volume: " << Volume << " ft3\n";
log << " Mass: " << GetMass() << " slug mass\n";
log << " Weight: " << GetMass()*slugtolb << " lbs force\n";

Check warning on line 835 in src/models/FGGasCell.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGasCell.cpp#L829-L835

Added lines #L829 - L835 were not covered by tests
}
if (debug_lvl & 16) { // Sanity checking
}
Expand Down
9 changes: 6 additions & 3 deletions src/models/FGGroundReactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "FGGroundReactions.h"
#include "FGAccelerations.h"
#include "input_output/FGXMLElement.h"
#include "input_output/FGLog.h"

using namespace std;

Expand Down Expand Up @@ -272,12 +273,14 @@

if (debug_lvl & 1) { // Standard console startup message output
if (from == 2) { // Loading
cout << endl << " Ground Reactions: " << endl;
FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG);
log << "\n Ground Reactions: \n";

Check warning on line 277 in src/models/FGGroundReactions.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGroundReactions.cpp#L276-L277

Added lines #L276 - L277 were not covered by tests
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification
if (from == 0) cout << "Instantiated: FGGroundReactions" << endl;
if (from == 1) cout << "Destroyed: FGGroundReactions" << endl;
FGLogging log(FDMExec->GetLogger(), LogLevel::DEBUG);
if (from == 0) log << "Instantiated: FGGroundReactions\n";
if (from == 1) log << "Destroyed: FGGroundReactions\n";

Check warning on line 283 in src/models/FGGroundReactions.cpp

View check run for this annotation

Codecov / codecov/patch

src/models/FGGroundReactions.cpp#L281-L283

Added lines #L281 - L283 were not covered by tests
}
if (debug_lvl & 4 ) { // Run() method entry print for FGModel-derived objects
}
Expand Down
Loading
Loading