Replace SG_GENERAL by more specific log classes in many places.
Allow "," to separate logging classes (using "|" is odd on the
command-line).
Also add new option to make logging more useful for developers.
You can use:
--log-level=debug --log-class=environment
to only get environment debug messages, or
--log-level=debug --log-class=sound,ai
to only get debug messages related to the sound or AI subsystem.
try {
readProperties(path.str(), &root);
} catch (const sg_exception &) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_AI, SG_ALERT,
"Error reading AI flight plan: " << path.str());
// cout << path.str() << endl;
return;
} // of node loop
wpt_iterator = waypoints.begin();
} catch (const sg_exception &e) {
- SG_LOG(SG_GENERAL, SG_WARN, "Error reading AI flight plan: " <<
+ SG_LOG(SG_AI, SG_WARN, "Error reading AI flight plan: " <<
e.getMessage() << " from " << e.getOrigin());
}
} else {
if (timeDiff >= 2000)
leg = 5;
*/
- SG_LOG(SG_GENERAL, SG_INFO, "Route from " << dep->getId() << " to " << arr->getId() << ". Set leg to : " << leg << " " << ac->getTrafficRef()->getCallSign());
+ SG_LOG(SG_AI, SG_INFO, "Route from " << dep->getId() << " to " << arr->getId() << ". Set leg to : " << leg << " " << ac->getTrafficRef()->getCallSign());
wpt_iterator = waypoints.begin();
bool dist = 0;
isValid = create(ac, dep,arr, leg, alt, speed, lat, lon,
break;
default:
//exit(1);
- SG_LOG(SG_INPUT, SG_ALERT,
+ SG_LOG(SG_AI, SG_ALERT,
"AIFlightPlan::create() attempting to create unknown leg"
" this is probably an internal program error");
}
&heading, &gateId,
radius, fltType,
acType, airline))) {
- SG_LOG(SG_INPUT, SG_WARN, "Could not find parking for a " <<
+ SG_LOG(SG_AI, SG_WARN, "Could not find parking for a " <<
acType <<
" of flight type " << fltType <<
" of airline " << airline <<
&heading, &gateId,
radius, fltType,
aircraftType, airline))) {
- SG_LOG(SG_INPUT, SG_WARN, "Warning: Could not find parking for a " <<
+ SG_LOG(SG_AI, SG_WARN, "Warning: Could not find parking for a " <<
aircraftType <<
" of flight type " << fltType <<
" of airline " << airline <<
pushBackWaypoint(wpt);
}
//cerr << "Success : GateId = " << gateId << endl;
- SG_LOG(SG_INPUT, SG_WARN, "Warning: Succesfully found a parking for a " <<
+ SG_LOG(SG_AI, SG_WARN, "Warning: Succesfully found a parking for a " <<
aircraftType <<
" of flight type " << fltType <<
" of airline " << airline <<
pushBackRoute = parking->getPushBackRoute();
int size = pushBackRoute->size();
if (size < 2) {
- SG_LOG(SG_GENERAL, SG_WARN, "Push back route from gate " << gateId << " has only " << size << " nodes.");
- SG_LOG(SG_GENERAL, SG_WARN, "Using " << pushBackNode);
+ SG_LOG(SG_AI, SG_WARN, "Push back route from gate " << gateId << " has only " << size << " nodes.");
+ SG_LOG(SG_AI, SG_WARN, "Using " << pushBackNode);
}
pushBackRoute->first();
while (pushBackRoute->next(&node, &rte))
// if the starting node equals the ending node, then there aren't any routes for this parking.
// in cases like these we should flag the gate as being inoperative and return false
if (ts == te) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Gate " << gateId << "doesn't seem to have routes associated with it.");
+ SG_LOG(SG_AI, SG_ALERT, "Gate " << gateId << "doesn't seem to have routes associated with it.");
parking->setAvailable(false);
return false;
}
tn = (*ts)->getEnd();
lastNodeVisited = tn->getIndex();
if (tn == NULL) {
- SG_LOG(SG_GENERAL, SG_ALERT, "No valid taxinode found");
+ SG_LOG(SG_AI, SG_ALERT, "No valid taxinode found");
exit(1);
}
double distance = (*ts)->getLength();
continue;
if (scenarios.find(name) != scenarios.end()) {
- SG_LOG(SG_GENERAL, SG_DEBUG, "won't load scenario '" << name << "' twice");
+ SG_LOG(SG_AI, SG_DEBUG, "won't load scenario '" << name << "' twice");
continue;
}
- SG_LOG(SG_GENERAL, SG_ALERT, "loading scenario '" << name << '\'');
+ SG_LOG(SG_AI, SG_ALERT, "loading scenario '" << name << '\'');
processScenario(name);
scenarios[name] = true;
}
readProperties(path.str(), root);
return root;
} catch (const sg_exception &t) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load scenario '"
+ SG_LOG(SG_AI, SG_ALERT, "Failed to load scenario '"
<< path.str() << "': " << t.getFormattedMessage());
return 0;
}
if (fabs(tgt_alt - alt) > tgt_ht[type] || type == FGAIBase::otBallistic
|| type == FGAIBase::otStorm || type == FGAIBase::otThermal ) {
- //SG_LOG(SG_GENERAL, SG_DEBUG, "AIManager: skipping "
+ //SG_LOG(SG_AI, SG_DEBUG, "AIManager: skipping "
// << fabs(tgt_alt - alt)
// << " "
// << type
double range = calcRange(lat, lon, tgt_lat, tgt_lon);
- //SG_LOG(SG_GENERAL, SG_DEBUG, "AIManager: AI list size "
+ //SG_LOG(SG_AI, SG_DEBUG, "AIManager: AI list size "
// << ai_list.size()
// << " type " << type
// << " ID " << id
tgt_length[type] += fuse_range;
if (range < tgt_length[type]){
- SG_LOG(SG_GENERAL, SG_DEBUG, "AIManager: HIT! "
+ SG_LOG(SG_AI, SG_DEBUG, "AIManager: HIT! "
<< " type " << type
<< " ID " << id
<< " range " << range
ai_list_type ai_list;
inline const ai_list_type& get_ai_list() const {
- SG_LOG(SG_GENERAL, SG_DEBUG, "AI Manager: AI model return list size " << ai_list.size());
+ SG_LOG(SG_AI, SG_DEBUG, "AI Manager: AI model return list size " << ai_list.size());
return ai_list;
}
try {
readProperties(filename.str(), &root);
} catch (const sg_exception &) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_AI, SG_ALERT,
"Error reading AI aircraft performance database: " << filename.str());
return;
}
if ( parent_subID == 0 || id == -1) // this entry in the list has no associated submodel
continue; // or is invalid so we can continue
- //SG_LOG(SG_GENERAL, SG_DEBUG, "Submodel: Impact " << _impact << " hit! "
+ //SG_LOG(SG_AI, SG_DEBUG, "Submodel: Impact " << _impact << " hit! "
// << _hit <<" parent_subID " << parent_subID);
_hit = (*sm_list_itr)->_getCollisionData();
_impact = (*sm_list_itr)->_getImpactData();
_expiry = (*sm_list_itr)->_getExpiryData();
- //SG_LOG(SG_GENERAL, SG_ALERT, "Submodel: " << (*sm_list_itr)->_getName()
+ //SG_LOG(SG_AI, SG_ALERT, "Submodel: " << (*sm_list_itr)->_getName()
// << " Impact " << _impact << " hit! " << _hit
// << " exipiry :-( " << _expiry );
if (_impact || _hit || _expiry) {
- // SG_LOG(SG_GENERAL, SG_ALERT, "Submodel: Impact " << _impact << " hit! " << _hit
+ // SG_LOG(SG_AI, SG_ALERT, "Submodel: Impact " << _impact << " hit! " << _hit
//<< " exipiry :-( " << _expiry );
submodel_iterator = submodels.begin();
while (submodel_iterator != submodels.end()) {
i++;
- /*SG_LOG(SG_GENERAL, SG_DEBUG,
+ /*SG_LOG(SG_AI, SG_DEBUG,
"Submodels: " << (*submodel_iterator)->id
<< " name " << (*submodel_iterator)->name
);*/
//int id = (*submodel_iterator)->id;
string name = (*submodel_iterator)->name;
- SG_LOG(SG_GENERAL, SG_DEBUG,
+ SG_LOG(SG_AI, SG_DEBUG,
"Submodels release: " << (*submodel_iterator)->id
<< " name " << (*submodel_iterator)->name
<< " count " << (*submodel_iterator)->count
void FGSubmodelMgr::loadAI()
{
- SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: Loading AI submodels ");
+ SG_LOG(SG_AI, SG_DEBUG, "Submodels: Loading AI submodels ");
FGAIManager::ai_list_type sm_list(aiManager()->get_ai_list());
if (sm_list.empty()) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Submodels: Unable to read AI submodel list");
+ SG_LOG(SG_AI, SG_ALERT, "Submodels: Unable to read AI submodel list");
return;
}
SGPath config = globals->resolve_aircraft_path(path);
try {
- SG_LOG(SG_GENERAL, SG_DEBUG,
+ SG_LOG(SG_AI, SG_DEBUG,
"Submodels: Trying to read AI submodels file: " << config.str());
readProperties(config.str(), &root);
} catch (const sg_exception &) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_AI, SG_ALERT,
"Submodels: Unable to read AI submodels file: " << config.str());
return;
}
SGPath config = globals->resolve_aircraft_path(path);
try {
- SG_LOG(SG_GENERAL, SG_DEBUG,
+ SG_LOG(SG_AI, SG_DEBUG,
"Submodels: Trying to read AI submodels file: " << config.str());
readProperties(config.str(), &root);
} catch (const sg_exception &) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_AI, SG_ALERT,
"Submodels: Unable to read AI submodels file: " << config.str());
return;
}
void FGSubmodelMgr::loadSubmodels()
{
- SG_LOG(SG_GENERAL, SG_DEBUG, "Submodels: Loading sub submodels");
+ SG_LOG(SG_AI, SG_DEBUG, "Submodels: Loading sub submodels");
_found_sub = false;
if (!submodel.empty()) {
//int id = (*submodel_iterator)->id;
bool serviceable = true;
- SG_LOG(SG_GENERAL, SG_DEBUG, "found path sub sub "
+ SG_LOG(SG_AI, SG_DEBUG, "found path sub sub "
<< submodel
<< " index " << index
<< " name " << (*submodel_iterator)->name);
// int id = (*submodel_iterator)->id;
// subcount++;
- // SG_LOG(SG_GENERAL, SG_ALERT,"after pushback "
+ // SG_LOG(SG_AI, SG_ALERT,"after pushback "
// << " parent id " << id
// << " name " << (*submodel_iterator)->name
// << " sub id " << (*submodel_iterator)->sub_id
//cout << name << " IC.speed " << IC.speed << endl;
} else {
- SG_LOG(SG_GENERAL, SG_ALERT, "AISubmodel: parent node not found ");
+ SG_LOG(SG_AI, SG_ALERT, "AISubmodel: parent node not found ");
}
}
fp = new FGAIFlightPlan;
while (park_index >= 0 && dcs->getParkingName(park_index) != parking) park_index--;
if (park_index < 0) {
- SG_LOG( SG_GENERAL, SG_ALERT,
+ SG_LOG( SG_ATC, SG_ALERT,
"Failed to find parking position " << parking <<
" at airport " << airport << " at " << SG_ORIGIN);
}
if (intentions.size()) {
intVecIterator i = intentions.begin();
if ((*i) != pos) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"Error in FGTrafficRecord::setPositionAndIntentions at " << SG_ORIGIN);
cerr << "Pos : " << pos << " Curr " << *(intentions.begin()) << endl;
for (intVecIterator i = intentions.begin();
}
// // update position of the current aircraft
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: updating aircraft without traffic record at " << SG_ORIGIN);
} else {
i->setPositionAndHeading(lat, lon, heading, speed, alt);
rwy->setCleared(0);
rwy->updateDepartureCue();
} else {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: Attempting to erase non-existing runway clearance record in FGTowerController::signoff at " << SG_ORIGIN);
}
}
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: Aircraft without traffic record is signing off from tower at " << SG_ORIGIN);
} else {
i->getAircraft()->resetTakeOffStatus();
}
}
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: checking ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
} else {
return i->hasInstruction();
}
}
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: requesting ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
} else {
return i->getInstruction();
}
}
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: checking ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
} else {
return i->hasInstruction();
}
}
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: requesting ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
} else {
return i->getInstruction();
}
}
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: Aircraft without traffic record is signing off from tower at " << SG_ORIGIN);
} else {
//cerr << i->getAircraft()->getCallSign() << " signing off from startupcontroller" << endl;
// // update position of the current aircraft
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: updating aircraft without traffic record at " << SG_ORIGIN);
} else {
i->setPositionAndHeading(lat, lon, heading, speed, alt);
}
// // update position of the current aircraft
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: updating aircraft without traffic record at " << SG_ORIGIN);
} else {
i->setPositionAndHeading(lat, lon, heading, speed, alt);
}
}
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: Aircraft without traffic record is signing off from approach at " << SG_ORIGIN);
} else {
i = activeTraffic.erase(i);
}
}
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: checking ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
} else {
return i->hasInstruction();
}
}
if (i == activeTraffic.end() || (activeTraffic.size() == 0)) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_ATC, SG_ALERT,
"AI error: requesting ATC instruction for aircraft without traffic record at " << SG_ORIGIN);
} else {
return i->getInstruction();
_sgr->add(simple, refname);
_sgr->play(refname, repeating);
} catch ( sg_io_exception &e ) {
- SG_LOG(SG_GENERAL, SG_ALERT, e.getFormattedMessage());
+ SG_LOG(SG_ATC, SG_ALERT, e.getFormattedMessage());
}
}
}
a.type = INVALID;
return fin >> skipeol;
default:
- SG_LOG(SG_GENERAL, SG_ALERT, "Warning - unknown type \'" << tp << "\' found whilst reading ATC frequency data!\n");
+ SG_LOG(SG_ATC, SG_ALERT, "Warning - unknown type \'" << tp << "\' found whilst reading ATC frequency data!\n");
a.type = INVALID;
return fin >> skipeol;
}
//cout << "Eradicating service: '" << svc->first << "'" << endl;
svc->second->SetNoDisplay();
svc->second->Update(0); // one last update
- SG_LOG(SG_GENERAL, SG_INFO, "would have erased ATC service:" << svc->second->get_name()<< "/"
+ SG_LOG(SG_ATC, SG_INFO, "would have erased ATC service:" << svc->second->get_name()<< "/"
<< svc->second->get_ident());
// delete svc->second;
atc_list->erase(svc);
FGFontCache *fc = globals->get_fontcache();
fntFont* font = fc->getTexFont(_font_name.c_str());
if (!font) {
- SG_LOG(SG_GENERAL, SG_WARN, "unable to find font:" << name);
+ SG_LOG(SG_COCKPIT, SG_WARN, "unable to find font:" << name);
}
}
&(torque[1]),&(lift[1])); //pitch b
rps[0]->calculateAlpha(v_wind,rho_null,0,0,0,
&(torque[3]),&(lift[3])); //pitch 0
- SG_LOG(SG_GENERAL, SG_INFO,
+ SG_LOG(SG_FLIGHT, SG_INFO,
"Rotor: coefficients for airfoil:" << endl << setprecision(6)
<< " drag0: " << _dragcoef0*_number_of_parts/_number_of_blades/_c2
<< " drag1: " << _dragcoef1*_number_of_parts/_number_of_blades/_c2
try {
readXML(f.str(), *_fdm);
} catch (const sg_exception &e) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_FLIGHT, SG_ALERT,
"Error reading YASim FDM: '" << f.str() << "'" << std::endl
<< e.getFormattedMessage());
throw e;
free_hostname = true;
}
- SG_LOG(SG_GENERAL, SG_INFO, "Scanning command line for: " << option );
+ SG_LOG(SG_INPUT, SG_INFO, "Scanning command line for: " << option );
int len = option.length();
while ( i < argc ) {
- SG_LOG( SG_GENERAL, SG_DEBUG, "argv[" << i << "] = " << argv[i] );
+ SG_LOG( SG_INPUT, SG_DEBUG, "argv[" << i << "] = " << argv[i] );
string arg = argv[i];
if ( arg.find( option ) == 0 ) {
return "";
}
- SG_LOG( SG_GENERAL, SG_INFO, "Scanning " << path << " for: " << option );
+ SG_LOG( SG_INPUT, SG_INFO, "Scanning " << path << " for: " << option );
int len = option.length();
if ( sound != NULL )
sound->set_volume( volume );
else
- SG_LOG( SG_GENERAL, SG_ALERT, "Can't find adf-ident sound" );
+ SG_LOG( SG_INSTR, SG_ALERT, "Can't find adf-ident sound" );
}
time_t cur_time = globals->get_time_params()->get_cur_time();
w.lat = rwy->begin().getLatitudeRad();
w.lon = rwy->begin().getLongitudeRad();
} catch(const sg_exception&) {
- SG_LOG(SG_GENERAL, SG_WARN, "Unable to find runway " << w.id.substr(2, 2) << " at airport " << iap->_aptIdent);
+ SG_LOG(SG_INSTR, SG_WARN, "Unable to find runway " << w.id.substr(2, 2) << " at airport " << iap->_aptIdent);
//cout << "Unable to find runway " << w.id.substr(2, 2) << " at airport " << iap->_aptIdent << " ( w.id = " << w.id << ", rwystr = " << rwystr << " )\n";
wp_error = true;
}
} else {
_g_error += (max_g_error /(erect_time * 0.33)) * dt * 2;
- //SG_LOG(SG_GENERAL, SG_ALERT,_num <<
+ //SG_LOG(SG_INSTR, SG_ALERT,_num <<
// " g input " << _g_in_node->getDoubleValue() * gravity
// <<" _erect_time " << _erect_time
// << " yaw " << yaw_rate
if ( diff < -180.0 ) { diff += 360.0; }
if ( diff > 180.0 ) { diff -= 360.0; }
_error_out_node->setDoubleValue( diff );
- //SG_LOG(SG_GENERAL, SG_ALERT,
+ //SG_LOG(SG_INSTR, SG_ALERT,
//"autopilot input " << bnode->getDoubleValue()
//<< " output " << _error_out_node->getDoubleValue()<<);
}
// rt->Reset("rgba ctt");
// if( rt->Initialize(256, 256, true) ) {
-// SG_LOG(SG_ALL, SG_INFO, "FGODGauge:Initialize sucessfull");
+// SG_LOG(SG_INSTR, SG_INFO, "FGODGauge:Initialize sucessfull");
// if (rt->BeginCapture())
// {
-// SG_LOG(SG_ALL, SG_INFO, "FGODGauge:BeginCapture sucessfull, RTT available");
+// SG_LOG(SG_INSTR, SG_INFO, "FGODGauge:BeginCapture sucessfull, RTT available");
// rtAvailable = true;
// glViewport(0, 0, textureWH, textureWH);
// glMatrixMode(GL_PROJECTION);
// glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
// rt->EndCapture();
// } else
-// SG_LOG(SG_ALL, SG_WARN, "FGODGauge:BeginCapture failed, RTT not available, using backbuffer");
+// SG_LOG(SG_INSTR, SG_WARN, "FGODGauge:BeginCapture failed, RTT not available, using backbuffer");
// } else
-// SG_LOG(SG_ALL, SG_WARN, "FGODGauge:Initialize failed, RTT not available, using backbuffer");
+// SG_LOG(SG_INSTR, SG_WARN, "FGODGauge:Initialize failed, RTT not available, using backbuffer");
}
FGODGauge::~FGODGauge() {
double ang2 = SGMiscd::normalizeAngle2(crs21-crs23);
if ((sin(ang1) == 0.0) && (sin(ang2) == 0.0)) {
- SG_LOG(SG_GENERAL, SG_WARN, "geocRadialIntersection: infinity of intersections");
+ SG_LOG(SG_INSTR, SG_WARN, "geocRadialIntersection: infinity of intersections");
return false;
}
if ((sin(ang1)*sin(ang2))<0.0) {
- SG_LOG(SG_GENERAL, SG_WARN, "geocRadialIntersection: intersection ambiguous");
+ SG_LOG(SG_INSTR, SG_WARN, "geocRadialIntersection: intersection ambiguous");
return false;
}
case RESTRICT_AT: {
double d = curAlt - _waypt->altitudeFt();
if (fabs(d) < 50.0) {
- SG_LOG(SG_GENERAL, SG_INFO, "ConstHdgToAltCtl, reached target altitude " << _waypt->altitudeFt());
+ SG_LOG(SG_INSTR, SG_INFO, "ConstHdgToAltCtl, reached target altitude " << _waypt->altitudeFt());
setDone();
}
} break;
case RESTRICT_ABOVE:
if (curAlt >= _waypt->altitudeFt()) {
- SG_LOG(SG_GENERAL, SG_INFO, "ConstHdgToAltCtl, above target altitude " << _waypt->altitudeFt());
+ SG_LOG(SG_INSTR, SG_INFO, "ConstHdgToAltCtl, above target altitude " << _waypt->altitudeFt());
setDone();
}
break;
case RESTRICT_BELOW:
if (curAlt <= _waypt->altitudeFt()) {
- SG_LOG(SG_GENERAL, SG_INFO, "ConstHdgToAltCtl, below target altitude " << _waypt->altitudeFt());
+ SG_LOG(SG_INSTR, SG_INFO, "ConstHdgToAltCtl, below target altitude " << _waypt->altitudeFt());
setDone();
}
break;
double r = SGGeodesy::courseDeg(_waypt->position(), _rnav->position());
SG_LOG(SG_AUTOPILOT, SG_INFO, "current radial=" << r);
if (fabs(r - _trueRadial) < 0.5) {
- SG_LOG(SG_GENERAL, SG_INFO, "InterceptCtl, intercepted radial " << _trueRadial);
+ SG_LOG(SG_INSTR, SG_INFO, "InterceptCtl, intercepted radial " << _trueRadial);
setDone();
}
}
_distanceNm = SGGeodesy::distanceNm(_rnav->position(), _dme->position());
double d = fabs(_distanceNm - _dme->dmeDistanceNm());
if (d < 0.1) {
- SG_LOG(SG_GENERAL, SG_INFO, "DMEInterceptCtl, intercepted DME " << _dme->dmeDistanceNm());
+ SG_LOG(SG_INSTR, SG_INFO, "DMEInterceptCtl, intercepted DME " << _dme->dmeDistanceNm());
setDone();
}
}
_radar_centre_node->setBoolValue(false);
}
- //SG_LOG(SG_GENERAL, SG_DEBUG, "Radar: displacement "
+ //SG_LOG(SG_INSTR, SG_DEBUG, "Radar: displacement "
// << _x_offset <<", "<<_y_offset
// << " user_speed_east_fps * SG_FPS_TO_KT "
// << user_speed_east_fps * SG_FPS_TO_KT
* wxRotate(angle) * _centerTrans);
addQuad(_vertices, _texCoords, m, texBase);
- //SG_LOG(SG_GENERAL, SG_DEBUG, "Radar: drawing clouds"
+ //SG_LOG(SG_INSTR, SG_DEBUG, "Radar: drawing clouds"
// << " ID=" << cloudId
// << " x=" << x
// << " y="<< y
* wxRotate(angle) * _centerTrans);
addQuad(_vertices, _texCoords, m, texBase);
- //SG_LOG(SG_GENERAL, SG_DEBUG, "Radar: drawing TACAN"
+ //SG_LOG(SG_INSTR, SG_DEBUG, "Radar: drawing TACAN"
// << " dist=" << radius
// << " view_heading=" << _view_heading * SG_RADIANS_TO_DEGREES
// << " bearing=" << angle * SG_RADIANS_TO_DEGREES
m *= _centerTrans;
addQuad(_vertices, _texCoords, m, texBase);
- //SG_LOG(SG_GENERAL, SG_DEBUG, "Radar: drawing heading marker"
+ //SG_LOG(SG_INSTR, SG_DEBUG, "Radar: drawing heading marker"
// << " x,y " << x <<","<< y
// << " dist" << dist
// << " view_heading" << _view_heading * SG_RADIANS_TO_DEGREES
alt = 0; // to allow some vertical extent of target
double radarhorizon = 1.23 * (sqrt(alt) + sqrt(user_alt));
-// SG_LOG(SG_GENERAL, SG_ALERT, "Radar: radar horizon " << radarhorizon);
+// SG_LOG(SG_INSTR, SG_ALERT, "Radar: radar horizon " << radarhorizon);
return radarhorizon >= range_nm;
}
constant = 35;
double maxrange = constant * pow(sigma, 0.25);
- //SG_LOG(SG_GENERAL, SG_DEBUG, "Radar: max range " << maxrange);
+ //SG_LOG(SG_INSTR, SG_DEBUG, "Radar: max range " << maxrange);
return maxrange >= range_nm;
}
/**
* Set the logging classes.
*/
-static void
+void
setLoggingClasses (const char * c)
{
string classes = c;
string rest = classes;
string name = "";
- int sep = rest.find('|');
- while (sep > 0) {
+ string::size_type sep = rest.find('|');
+ if (sep == string::npos)
+ sep = rest.find(',');
+ while (sep != string::npos) {
name = rest.substr(0, sep);
rest = rest.substr(sep+1);
addLoggingClass(name);
sep = rest.find('|');
+ if (sep == string::npos)
+ sep = rest.find(',');
}
addLoggingClass(rest);
SG_LOG(SG_GENERAL, SG_INFO, "Set logging classes to "
/**
* Set the logging priority.
*/
-static void
+void
setLoggingPriority (const char * p)
{
if (p == 0)
extern bool fgLoadProps (const char * path, SGPropertyNode * props,
bool in_fg_root = true, int default_mode = 0);
+void setLoggingClasses (const char * c);
+void setLoggingPriority (const char * p);
\f
////////////////////////////////////////////////////////////////////////
static int
fgOptLogLevel( const char *arg )
{
- fgSetString("/sim/logging/classes", "all");
fgSetString("/sim/logging/priority", arg);
-
- string priority = arg;
- logbuf::set_log_classes(SG_ALL);
- if (priority == "bulk") {
- logbuf::set_log_priority(SG_BULK);
- } else if (priority == "debug") {
- logbuf::set_log_priority(SG_DEBUG);
- } else if (priority == "info") {
- logbuf::set_log_priority(SG_INFO);
- } else if (priority == "warn") {
- logbuf::set_log_priority(SG_WARN);
- } else if (priority == "alert") {
- logbuf::set_log_priority(SG_ALERT);
- } else {
- SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging priority " << priority);
- }
- SG_LOG(SG_GENERAL, SG_DEBUG, "Logging priority is " << priority);
+ setLoggingPriority(arg);
return FG_OPTIONS_OK;
}
+static int
+fgOptLogClasses( const char *arg )
+{
+ fgSetString("/sim/logging/classes", arg);
+ setLoggingClasses (arg);
+
+ return FG_OPTIONS_OK;
+}
static int
fgOptTraceWrite( const char *arg )
{"trace-read", true, OPTION_FUNC | OPTION_MULTI, "", false, "", fgOptTraceRead },
{"trace-write", true, OPTION_FUNC | OPTION_MULTI, "", false, "", fgOptTraceWrite },
{"log-level", true, OPTION_FUNC, "", false, "", fgOptLogLevel },
+ {"log-class", true, OPTION_FUNC, "", false, "", fgOptLogClasses },
{"view-offset", true, OPTION_FUNC | OPTION_MULTI, "", false, "", fgOptViewOffset },
{"visibility", true, OPTION_FUNC, "", false, "", fgOptVisibilityMeters },
{"visibility-miles", true, OPTION_FUNC, "", false, "", fgOptVisibilityMiles },
osg::Node *model = fgLoad3DModelPanel( path, globals->get_props());
_aircraft->init( model );
} catch (const sg_exception &ex) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Failed to load aircraft from " << path << ':');
- SG_LOG(SG_GENERAL, SG_ALERT, " " << ex.getFormattedMessage());
- SG_LOG(SG_GENERAL, SG_ALERT, "(Falling back to glider.ac.)");
+ SG_LOG(SG_AIRCRAFT, SG_ALERT, "Failed to load aircraft from " << path << ':');
+ SG_LOG(SG_AIRCRAFT, SG_ALERT, " " << ex.getFormattedMessage());
+ SG_LOG(SG_AIRCRAFT, SG_ALERT, "(Falling back to glider.ac.)");
osg::Node *model = fgLoad3DModelPanel( "Models/Geometry/glider.ac",
globals->get_props());
_aircraft->init( model );
void
FGModelMgr::add_model (SGPropertyNode * node)
{
- SG_LOG(SG_GENERAL, SG_INFO,
+ SG_LOG(SG_AIRCRAFT, SG_INFO,
"Adding model " << node->getStringValue("name", "[unnamed]"));
const char *path = node->getStringValue("path", "Models/Geometry/glider.ac");
try {
object = SGModelLib::loadDeferredModel(path, globals->get_props());
} catch (const sg_throwable& t) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Error loading " << path << ":\n "
+ SG_LOG(SG_AIRCRAFT, SG_ALERT, "Error loading " << path << ":\n "
<< t.getFormattedMessage() << t.getOrigin());
return;
}
} catch (const sg_range_exception&) {
const char *path = instance->node->getStringValue("path",
"unknown");
- SG_LOG(SG_GENERAL, SG_INFO, "Instance of model " << path
+ SG_LOG(SG_AIRCRAFT, SG_INFO, "Instance of model " << path
<< " has invalid values");
return;
}
SGPath atcsim_config( envp );
atcsim_config.append( ".fgfs-atc610x.xml" );
try {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_NETWORK, SG_ALERT,
"Warning: loading deprecated config file: " <<
atcsim_config.str() );
readProperties( atcsim_config.str(), globals->get_props() );
FGNasalSys *n = (FGNasalSys*)globals->get_subsystem("nasal");
bool result = n->parseAndRun( "atcsim.update()" );
if ( !result ) {
- SG_LOG( SG_GENERAL, SG_ALERT, "Nasal: atcsim.update() failed!" );
+ SG_LOG( SG_NETWORK, SG_ALERT, "Nasal: atcsim.update() failed!" );
}
// process the ATC outputs
}
if (configToken >= tokens.size()) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_NETWORK, SG_ALERT,
"Not enough tokens passed for generic protocol");
return;
}
direction = tokens[2];
if (direction != "in" && direction != "out" && direction != "bi") {
- SG_LOG(SG_GENERAL, SG_ALERT, "Unsuported protocol direction: "
+ SG_LOG(SG_NETWORK, SG_ALERT, "Unsuported protocol direction: "
<< direction);
}
path.append("Protocol");
path.append(file_name.c_str());
- SG_LOG(SG_GENERAL, SG_INFO, "Reading communication protocol from "
+ SG_LOG(SG_NETWORK, SG_INFO, "Reading communication protocol from "
<< path.str());
SGPropertyNode root;
try {
readProperties(path.str(), &root);
} catch (const sg_exception & ex) {
- SG_LOG(SG_GENERAL, SG_ALERT,
+ SG_LOG(SG_NETWORK, SG_ALERT,
"Unable to load the protocol configuration file: " << ex.getFormattedMessage() );
return;
}
if ( !globals->get_commands()
->execute(urlDecode(b).c_str(), &args) )
{
- SG_LOG( SG_GENERAL, SG_ALERT,
+ SG_LOG( SG_NETWORK, SG_ALERT,
"Command " << urlDecode(b)
<< " failed.");
}
if ( !globals->get_commands()
->execute( "reinit", &args) )
{
- SG_LOG( SG_GENERAL, SG_ALERT,
+ SG_LOG( SG_NETWORK, SG_ALERT,
"Command " << tokens[1] << " failed.");
if ( mode == PROMPT ) {
tmp += "*failed*";
if ( !globals->get_commands()
->execute(tokens[1].c_str(), &args) )
{
- SG_LOG( SG_GENERAL, SG_ALERT,
+ SG_LOG( SG_NETWORK, SG_ALERT,
"Command " << tokens[1] << " failed.");
if ( mode == PROMPT ) {
tmp += "*failed*";
{
double dv = p->getDoubleValue();
if (osg::isNaN(dv)) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Nasal getprop: property " << p->getPath() << " is NaN");
+ SG_LOG(SG_NASAL, SG_ALERT, "Nasal getprop: property " << p->getPath() << " is NaN");
return naNil();
}
if(naIsNil(s)) continue;
buf += naStr_data(s);
}
- SG_LOG(SG_GENERAL, SG_ALERT, buf);
+ SG_LOG(SG_NASAL, SG_ALERT, buf);
return naNum(buf.length());
}
{
double dv = (*node)->getDoubleValue();
if (osg::isNaN(dv)) {
- SG_LOG(SG_GENERAL, SG_ALERT, "Nasal getValue: property " << (*node)->getPath() << " is NaN");
+ SG_LOG(SG_NASAL, SG_ALERT, "Nasal getValue: property " << (*node)->getPath() << " is NaN");
return naNil();
}