[generator] Improve logging

- more logging for various stages start/finish
- silenced some too repetitive and common warnings (changed to LDEBUG)

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-09-04 17:34:18 +07:00
parent 9e38cff708
commit 76cb6803c2
17 changed files with 42 additions and 13 deletions

View File

@@ -33,7 +33,7 @@ AddressesHolder::AddressInfo FromFB(FeatureBuilder const & fb)
// - "addr:interpolation: No beg/end address point" = 89774
void LogWarning(std::string const & msg, uint64_t id)
{
LOG(LWARNING, ("addr:interpolation: " + msg, id));
LOG(LDEBUG, ("addr:interpolation: " + msg, id));
}
} // namespace
@@ -190,6 +190,8 @@ void AddressesCollector::CollectFeature(FeatureBuilder const & fb, OsmElement co
void AddressesCollector::Save()
{
LOG(LINFO, ("Saving addresses to", GetFilename()));
FileWriter writer(GetFilename());
for (auto const & e : m_interpolWays)
@@ -215,6 +217,8 @@ void AddressesCollector::Save()
rw::Write(writer, !beg->m_street.empty() ? beg->m_street : end->m_street);
rw::Write(writer, !beg->m_postcode.empty() ? beg->m_postcode : end->m_postcode);
}
LOG(LINFO, ("Finished saving addresses"));
}
void AddressesCollector::MergeInto(AddressesCollector & collector) const

View File

@@ -52,6 +52,7 @@ void BoundaryPostcodeCollector::Collect(OsmElement const & el)
void BoundaryPostcodeCollector::Save()
{
LOG(LINFO, ("Saving postcode boundaries to", GetFilename()));
std::sort(m_data.begin(), m_data.end());
FileWriter writer(GetFilename());
@@ -60,6 +61,8 @@ void BoundaryPostcodeCollector::Save()
rw::WriteNonEmpty(writer, p.first);
rw::WriteVectorOfPOD(writer, p.second);
}
LOG(LINFO, ("Finished saving postcode boundaries"));
}
void BoundaryPostcodeCollector::MergeInto(BoundaryPostcodeCollector & collector) const

View File

@@ -130,12 +130,14 @@ void CameraCollector::MergeInto(CameraCollector & collector) const
void CameraCollector::Save()
{
LOG(LINFO, ("Saving speed cameras to", GetFilename()));
LOG(LINFO, ("Associating speed cameras with ways..."));
FillCameraInWays();
LOG(LINFO, ("Saving speed cameras to", GetFilename()));
FileWriter writer(GetFilename());
ForEachCamera([&](auto const & camera) { CameraInfo::Write(writer, camera); });
LOG(LINFO, ("Finished saving speed cameras"));
}
void CameraCollector::OrderCollectedData()

View File

@@ -47,6 +47,7 @@ void MiniRoundaboutCollector::CollectFeature(FeatureBuilder const & feature, Osm
void MiniRoundaboutCollector::Save()
{
LOG(LINFO, ("Saving mini roundabouts to", GetFilename()));
/// @todo We assign only car roads here into MiniRoundaboutInfo.m_ways.
/// Should also collect other highways (like path or pedestrian) in very general case.
/// https://www.openstreetmap.org/way/220672898
@@ -66,6 +67,7 @@ void MiniRoundaboutCollector::Save()
if (miniRoundabout.Normalize())
WriteMiniRoundabout(writer, miniRoundabout);
});
LOG(LINFO, ("Finished saving mini roundabouts"));
}
void MiniRoundaboutCollector::MergeInto(MiniRoundaboutCollector & collector) const

View File

@@ -443,7 +443,9 @@ void RoutingCityBoundariesCollector::Collect(OsmElement const & elem)
void RoutingCityBoundariesCollector::Save()
{
LOG(LINFO, ("Saving routing city boundaries to", GetFilename()));
m_builder.Save(GetFilename());
LOG(LINFO, ("Finished saving routing city boundaries"));
}
void RoutingCityBoundariesCollector::MergeInto(RoutingCityBoundariesCollector & collector) const

View File

@@ -20,6 +20,8 @@ void FinalProcessorCities::Process()
{
using namespace feature;
LOG(LINFO, ("Processing cities..."));
std::mutex mutex;
auto const & localityChecker = ftypes::IsLocalityChecker::Instance();

View File

@@ -22,6 +22,7 @@ void CoastlineFinalProcessor::SetCoastlinesFilenames(std::string const & geomFil
void CoastlineFinalProcessor::Process()
{
LOG(LINFO, ("Processing coastline..."));
ForEachFeatureRawFormat<serialization_policy::MaxAccuracy>(
m_filename, [this](FeatureBuilder const & fb, uint64_t) { m_generator.Process(fb); });
@@ -29,7 +30,7 @@ void CoastlineFinalProcessor::Process()
// Check and stop if some coasts were not merged.
CHECK(m_generator.Finish(), ());
LOG(LINFO, ("Generating coastline polygons."));
LOG(LINFO, ("Generating coastline polygons..."));
size_t totalFeatures = 0;
size_t totalPoints = 0;
size_t totalPolygons = 0;
@@ -41,6 +42,6 @@ void CoastlineFinalProcessor::Process()
totalPolygons += fb.GetPolygonsCount();
}
LOG(LINFO, ("Total features:", totalFeatures, "total polygons:", totalPolygons, "total points:", totalPoints));
LOG(LINFO, ("Total coastline features:", totalFeatures, "total polygons:", totalPolygons, "total points:", totalPoints));
}
} // namespace generator

View File

@@ -63,6 +63,8 @@ void ComplexFinalProcessor::UseBuildingPartsInfo(std::string const & filename)
void ComplexFinalProcessor::Process()
{
LOG(LINFO, ("Processing complex features..."));
if (!m_buildingPartsFilename.empty())
m_buildingToParts = std::make_unique<BuildingToBuildingPartsMap>(m_buildingPartsFilename);

View File

@@ -46,24 +46,30 @@ void CountryFinalProcessor::Process()
/// @todo Make "straight-way" processing. There is no need to make many functions and
/// many read-write FeatureBuilder ops here.
LOG(LINFO, ("Processing coastline..."));
if (!m_coastlineGeomFilename.empty())
ProcessCoastline();
// 1. Process roundabouts and addr:interpolation first.
LOG(LINFO, ("Processing roundabouts..."));
if (!m_miniRoundaboutsFilename.empty() || !m_addrInterpolFilename.empty())
ProcessRoundabouts();
// 2. Process additional addresses then.
LOG(LINFO, ("Adding addresses..."));
if (!m_addressPath.empty())
AddAddresses();
LOG(LINFO, ("Adding fake nodes..."));
if (!m_fakeNodesFilename.empty())
AddFakeNodes();
LOG(LINFO, ("Adding isolines..."));
if (!m_isolinesPath.empty())
AddIsolines();
// DropProhibitedSpeedCameras();
LOG(LINFO, ("Processing building parts..."));
ProcessBuildingParts();
// Finish();

View File

@@ -23,11 +23,11 @@ void WorldFinalProcessor::Process()
auto fbs = ReadAllDatRawFormat<serialization_policy::MaxAccuracy>(m_worldTmpFilename);
Order(fbs);
WorldGenerator generator(m_worldTmpFilename, m_coastlineGeomFilename, m_popularPlacesFilename);
LOG(LINFO, ("Process World features"));
LOG(LINFO, ("Processing World features..."));
for (auto & fb : fbs)
generator.Process(fb);
LOG(LINFO, ("Merge World lines"));
LOG(LINFO, ("Merging World lines..."));
generator.DoMerge();
}

View File

@@ -199,6 +199,8 @@ void MetalinesBuilder::Finish()
void MetalinesBuilder::Save()
{
LOG(LINFO, ("Saving metalines to", GetFilename()));
std::unordered_multimap<size_t, std::shared_ptr<LineString>> keyToLineString;
FileReader reader(GetTmpFilename());
ReaderSource<FileReader> src(reader);
@@ -223,8 +225,7 @@ void MetalinesBuilder::Save()
}
}
LOG_SHORT(LINFO, ("Wrote", countLines, "metalines [with", countWays, "ways] with OSM IDs for the entire planet to",
GetFilename()));
LOG(LINFO, ("Finished saving metalines. Wrote", countLines, "metalines [with", countWays, "ways]"));
}
void MetalinesBuilder::OrderCollectedData()

View File

@@ -1470,10 +1470,10 @@ void GetNameAndType(OsmElement * p, FeatureBuilderParams & params, TypesFilterFn
size_t const typesCount = params.m_types.size();
if (params.FinishAddingTypesEx() == FeatureParams::TYPES_EXCEED_MAX)
LOG(LWARNING, ("Exceeded types count for:", DebugPrintID(*p), "Types:", typesCount, typesString));
LOG(LDEBUG, ("Exceeded types count for:", DebugPrintID(*p), "Types:", typesCount, typesString));
if (!params.house.IsEmpty() && !ftypes::IsAddressObjectChecker::Instance()(params.m_types))
LOG(LWARNING, ("Have house number for _non-address_:", DebugPrintID(*p), "Types:", typesString));
LOG(LDEBUG, ("Have house number for _non-address_:", DebugPrintID(*p), "Types:", typesString));
}
// Stage6: Collect additional information about feature such as

View File

@@ -265,6 +265,7 @@ bool RawGenerator::GenerateFilteredFeatures()
while (!isEnd);
LOG(LINFO, ("OSM source input was processed."));
LOG(LINFO, ("Finishing translators..."));
if (!translators.Finish())
return false;

View File

@@ -188,6 +188,7 @@ void RestrictionWriter::Finish()
void RestrictionWriter::Save()
{
CHECK(!m_stream.is_open(), ("Finish() has not been called."));
LOG(LINFO, ("Saving restriction values to", GetFilename()));
if (Platform::IsFileExistsByFullPath(GetTmpFilename()))
CHECK(base::CopyFileX(GetTmpFilename(), GetFilename()), ());
}

View File

@@ -453,7 +453,7 @@ void RoadAccessCollector::Save()
{
// Dump only bicycle profile with the most wide barriers set to ignore.
if (p.m_vehicleType == VehicleType::Bicycle)
LOG(LWARNING, ("Node barrier without access:", nodeID));
LOG(LDEBUG, ("Node barrier without access:", nodeID));
continue;
}
}
@@ -467,6 +467,8 @@ void RoadAccessCollector::Save()
}, m_cache);
sizeWriter.Write(writer, count);
LOG(LINFO, ("Finished saving road access values"));
}
void RoadAccessCollector::MergeInto(RoadAccessCollector & collector) const

View File

@@ -220,6 +220,8 @@ void RoadPenaltyCollector::Save()
routing::Save(writer, entry.type);
}
}
LOG(LINFO, ("Finished saving road penalty values"));
}
bool BuildRoadPenalty(string const & dataFilePath, string const & roadPenaltyPath,

View File

@@ -62,9 +62,7 @@ void Translator::Emit(OsmElement const & src)
void Translator::Finish()
{
LOG(LINFO, ("Finishing collectors..."));
m_collector->Finish();
LOG(LINFO, ("Finishing processors..."));
m_processor->Finish();
}