From 968e94e897838ef1f4b75e48aabd9b38c3edcf79 Mon Sep 17 00:00:00 2001 From: "Cimon Lucas (LCM)" Date: Tue, 21 Jan 2025 17:57:42 +0100 Subject: [PATCH] WIP --- .pkg.mutex | 0 include/nigiri/footpath.h | 3 +- .../loader/hrd/service/expand_local_to_utc.h | 8 +- .../nigiri/loader/hrd/service/read_services.h | 9 +- include/nigiri/timetable.h | 1 + src/abi.cc | 21 +++-- src/loader/assistance.cc | 21 ++--- src/loader/build_footpaths.cc | 4 +- src/loader/dir.cc | 4 +- src/loader/gtfs/load_timetable.cc | 2 +- src/loader/gtfs/route.cc | 3 +- src/loader/gtfs/stop.cc | 4 +- src/loader/gtfs/stop_time.cc | 7 +- src/loader/gtfs/trip.cc | 16 ++-- src/loader/hrd/load_timetable.cc | 10 +-- src/loader/hrd/service/service_builder.cc | 5 +- src/loader/hrd/stamm/attribute.cc | 2 +- src/loader/hrd/stamm/category.cc | 3 +- src/loader/hrd/stamm/stamm.cc | 2 +- src/loader/hrd/stamm/station.cc | 88 ++++++++++--------- src/loader/hrd/stamm/timezone.cc | 4 +- src/loader/hrd/stamm/track.cc | 2 +- src/loader/load.cc | 1 + src/query_generator/generator.cc | 6 +- src/routing/dijkstra.cc | 3 +- src/routing/ontrip_train.cc | 4 +- src/routing/start_times.cc | 4 +- src/rt/frun.cc | 5 +- src/rt/gtfsrt_update.cc | 29 +++--- src/rt/vdv/vdv_update.cc | 7 +- src/scoped_timer.cc | 5 +- 31 files changed, 156 insertions(+), 127 deletions(-) mode change 100755 => 100644 .pkg.mutex diff --git a/.pkg.mutex b/.pkg.mutex old mode 100755 new mode 100644 diff --git a/include/nigiri/footpath.h b/include/nigiri/footpath.h index cf122031d..5149f197d 100644 --- a/include/nigiri/footpath.h +++ b/include/nigiri/footpath.h @@ -2,12 +2,11 @@ #include "fmt/ostream.h" -#include "utl/verify.h" #include "utl/logging.h" +#include "utl/verify.h" #include "cista/reflection/printable.h" -#include "nigiri/footpath.h" #include "nigiri/types.h" namespace nigiri { diff --git a/include/nigiri/loader/hrd/service/expand_local_to_utc.h b/include/nigiri/loader/hrd/service/expand_local_to_utc.h index e96a2b123..5ac50c543 100644 --- a/include/nigiri/loader/hrd/service/expand_local_to_utc.h +++ b/include/nigiri/loader/hrd/service/expand_local_to_utc.h @@ -1,5 +1,7 @@ #pragma once +#include "utl/logging.h" + #include "nigiri/loader/hrd/service/ref_service.h" #include "nigiri/loader/hrd/service/service.h" #include "nigiri/loader/hrd/stamm/timezone.h" @@ -55,7 +57,8 @@ std::optional build_utc_time_seq( stop_timezones.front(), day, local_times.front(), true); if (!first_valid) { - utl::log_error("loader.hrd.service.utc", + utl::log_error( + "loader.hrd.service.utc", "first departure local to utc failed for {}: local_time={}, day={}", origin, local_times.front(), day); return std::nullopt; @@ -67,7 +70,8 @@ std::optional build_utc_time_seq( auto const [utc_mam, day_offset, valid] = local_mam_to_utc_mam( tz, day + first_day_offset, local_time - first_day_offset); if (day_offset != 0_days || pred > utc_mam || !valid) { - utl::log_error("loader.hrd.service.utc", + utl::log_error( + "loader.hrd.service.utc", "local to utc failed, ignoring: {}, day={}, time={}, offset={}, " "pred={}, utc_mam={}, valid={}", origin, day, local_time, day_offset, pred, utc_mam, valid); diff --git a/include/nigiri/loader/hrd/service/read_services.h b/include/nigiri/loader/hrd/service/read_services.h index 617d9e4fe..e1d5b9aa7 100644 --- a/include/nigiri/loader/hrd/service/read_services.h +++ b/include/nigiri/loader/hrd/service/read_services.h @@ -1,5 +1,6 @@ #pragma once +#include "utl/logging.h" #include "utl/parser/cstr.h" #include "nigiri/loader/hrd/service/expand_local_to_utc.h" @@ -55,16 +56,16 @@ void parse_services(config const& c, } if (!spec.valid()) { - utl::log_error("loader.hrd.service", - "skipping invalid service at {}:{}", filename, line_number); + utl::log_error("loader.hrd.service", "skipping invalid service at {}:{}", + filename, line_number); } else if (!spec.ignore()) { // Store if relevant. try { expand_service(store.add(service{c, st, source_file_idx, spec})); } catch (std::exception const& e) { utl::log_error("loader.hrd.service.expand", - "unable to build service at {}:{}: {}", filename, line_number, - e.what()); + "unable to build service at {}:{}: {}", filename, + line_number, e.what()); } } diff --git a/include/nigiri/timetable.h b/include/nigiri/timetable.h index f2d85e463..ce979490d 100644 --- a/include/nigiri/timetable.h +++ b/include/nigiri/timetable.h @@ -8,6 +8,7 @@ #include "cista/memory_holder.h" #include "cista/reflection/printable.h" +#include "utl/logging.h" #include "utl/verify.h" #include "utl/zip.h" diff --git a/src/abi.cc b/src/abi.cc index 85dda2bd4..5fc31266c 100644 --- a/src/abi.cc +++ b/src/abi.cc @@ -4,34 +4,33 @@ #include #include +#include "cista/memory_holder.h" + #include "date/date.h" #include "utl/helpers/algorithm.h" +#include "utl/logging.h" #include "utl/overloaded.h" #include "utl/progress_tracker.h" #include "utl/verify.h" -#include "nigiri/abi.h" - #include "nigiri/loader/dir.h" #include "nigiri/loader/gtfs/loader.h" #include "nigiri/loader/hrd/loader.h" #include "nigiri/loader/init_finish.h" +#include "nigiri/abi.h" +#include "nigiri/common/interval.h" +#include "nigiri/routing/journey.h" +#include "nigiri/routing/raptor/raptor.h" +#include "nigiri/routing/search.h" #include "nigiri/rt/create_rt_timetable.h" +#include "nigiri/rt/frun.h" #include "nigiri/rt/gtfsrt_update.h" #include "nigiri/rt/rt_timetable.h" #include "nigiri/shapes_storage.h" #include "nigiri/timetable.h" #include "nigiri/types.h" -#include "nigiri/routing/journey.h" -#include "nigiri/routing/raptor/raptor.h" -#include "nigiri/routing/search.h" -#include "nigiri/rt/frun.h" - -#include "nigiri/common/interval.h" -#include "cista/memory_holder.h" - using namespace date; struct nigiri_timetable { @@ -61,7 +60,7 @@ nigiri_timetable_t* nigiri_load_from_dir(nigiri::loader::dir const& d, utl::find_if(loaders, [&](auto&& l) { return l->applicable(d); }); utl::verify(c != end(loaders), "no loader applicable to the given file(s)"); utl::log_info("main", "loading nigiri timetable with configuration {}", - (*c)->name()); + (*c)->name()); auto t = new nigiri_timetable_t; t->tt = std::make_unique(); diff --git a/src/loader/assistance.cc b/src/loader/assistance.cc index ae42001d3..efa522171 100644 --- a/src/loader/assistance.cc +++ b/src/loader/assistance.cc @@ -23,16 +23,17 @@ assistance_times read_assistance(std::string_view file_content) { auto a = assistance_times{}; utl::line_range{utl::make_buf_reader(file_content)} // | utl::csv() // - | utl::for_each([&](assistance const& x) { - a.names_.emplace_back(x.name_->trim().view()); - a.pos_.emplace_back(*x.lat_, *x.lng_); - try { - a.rules_.emplace_back(oh::parse(x.time_->trim().view())); - } catch (std::exception const& e) { - utl::log_error("loader.assistance", - "bad assistance time \"{}\": {}", x.time_->view(), e.what()); - } - }); + | + utl::for_each([&](assistance const& x) { + a.names_.emplace_back(x.name_->trim().view()); + a.pos_.emplace_back(*x.lat_, *x.lng_); + try { + a.rules_.emplace_back(oh::parse(x.time_->trim().view())); + } catch (std::exception const& e) { + utl::log_error("loader.assistance", "bad assistance time \"{}\": {}", + x.time_->view(), e.what()); + } + }); a.rtree_ = geo::make_point_rtree(a.pos_); return a; } diff --git a/src/loader/build_footpaths.cc b/src/loader/build_footpaths.cc index ae1d7582d..1231d0413 100644 --- a/src/loader/build_footpaths.cc +++ b/src/loader/build_footpaths.cc @@ -19,8 +19,8 @@ #include "nigiri/common/day_list.h" #include "nigiri/constants.h" #include "nigiri/routing/dijkstra.h" -#include "nigiri/scoped_timer.h" #include "nigiri/rt/frun.h" +#include "nigiri/scoped_timer.h" #include "nigiri/types.h" namespace nigiri::loader { @@ -303,7 +303,7 @@ void connect_components(timetable& tt, static_cast(distance / kWalkSpeed / 60)); if (adjusted_int > std::numeric_limits::max()) { utl::log_error("loader.footpath.adjust", - "too long after adjust: {}>256", adjusted_int); + "too long after adjust: {}>256", adjusted_int); } adjusted = u8_minutes{adjusted_int}; } diff --git a/src/loader/dir.cc b/src/loader/dir.cc index b7cda2276..cbf72ab69 100644 --- a/src/loader/dir.cc +++ b/src/loader/dir.cc @@ -73,8 +73,8 @@ file fs_dir::get_file(std::filesystem::path const& p) const { mmap_content& operator=(mmap_content const&) = delete; explicit mmap_content(std::filesystem::path const& p) : mmap_{p.string().c_str(), cista::mmap::protection::READ} { - utl::log_info("loader.fs_dir", "loaded {}: {} bytes", - p.generic_string(), mmap_.size()); + utl::log_info("loader.fs_dir", "loaded {}: {} bytes", p.generic_string(), + mmap_.size()); } ~mmap_content() final = default; std::string_view get() const final { return mmap_.view(); } diff --git a/src/loader/gtfs/load_timetable.cc b/src/loader/gtfs/load_timetable.cc index 1d89e2e29..871ba9972 100644 --- a/src/loader/gtfs/load_timetable.cc +++ b/src/loader/gtfs/load_timetable.cc @@ -13,7 +13,6 @@ #include "wyhash.h" -#include "nigiri/common/sort_by.h" #include "nigiri/loader/get_index.h" #include "nigiri/loader/gtfs/agency.h" #include "nigiri/loader/gtfs/calendar.h" @@ -31,6 +30,7 @@ #include "nigiri/loader/gtfs/stop_time.h" #include "nigiri/loader/gtfs/trip.h" #include "nigiri/loader/loader_interface.h" +#include "nigiri/common/sort_by.h" #include "nigiri/scoped_timer.h" #include "nigiri/timetable.h" diff --git a/src/loader/gtfs/route.cc b/src/loader/gtfs/route.cc index cfd5ccf31..f14b34dee 100644 --- a/src/loader/gtfs/route.cc +++ b/src/loader/gtfs/route.cc @@ -177,7 +177,8 @@ route_map_t read_routes(timetable& tt, agencies.size() == 1U ? agencies.begin()->second : utl::get_or_create(agencies, r.agency_id_->view(), [&]() { - utl::log_error("gtfs.route", + utl::log_error( + "gtfs.route", "agency {} not found, using UNKNOWN with local " "timezone", r.agency_id_->view()); diff --git a/src/loader/gtfs/stop.cc b/src/loader/gtfs/stop.cc index e6b681576..c5d2d4cd8 100644 --- a/src/loader/gtfs/stop.cc +++ b/src/loader/gtfs/stop.cc @@ -133,14 +133,14 @@ void read_transfers(stop_map_t& stops, std::string_view file_content) { auto const from_stop_it = stops.find(t.from_stop_id_->view()); if (from_stop_it == end(stops)) { utl::log_error("loader.gtfs.transfers", "stop {} not found\n", - t.from_stop_id_->view()); + t.from_stop_id_->view()); return; } auto const to_stop_it = stops.find(t.to_stop_id_->view()); if (to_stop_it == end(stops)) { utl::log_error("loader.gtfs.transfers", "stop {} not found\n", - t.to_stop_id_->view()); + t.to_stop_id_->view()); return; } diff --git a/src/loader/gtfs/stop_time.cc b/src/loader/gtfs/stop_time.cc index 0868f4fde..d496985fd 100644 --- a/src/loader/gtfs/stop_time.cc +++ b/src/loader/gtfs/stop_time.cc @@ -15,9 +15,9 @@ #include "utl/pipes/vec.h" #include "utl/progress_tracker.h" -#include "nigiri/common/cached_lookup.h" #include "nigiri/loader/gtfs/parse_time.h" #include "nigiri/loader/gtfs/trip.h" +#include "nigiri/common/cached_lookup.h" #include "nigiri/scoped_timer.h" namespace nigiri::loader::gtfs { @@ -79,7 +79,7 @@ void read_stop_times(timetable& tt, auto const trip_it = trips.trips_.find(t_id); if (trip_it == end(trips.trips_)) { utl::log_error("loader.gtfs.stop_time", - "stop_times.txt:{} trip \"{}\" not found", i, t_id); + "stop_times.txt:{} trip \"{}\" not found", i, t_id); return; } t = &trips.data_[trip_it->second]; @@ -121,7 +121,8 @@ void read_stop_times(timetable& tt, } } catch (...) { utl::log_error("loader.gtfs.stop_time", - "stop_times.txt:{}: unknown stop \"{}\"", i, s.stop_id_->view()); + "stop_times.txt:{}: unknown stop \"{}\"", i, + s.stop_id_->view()); } }); diff --git a/src/loader/gtfs/trip.cc b/src/loader/gtfs/trip.cc index 5fd4d9859..ccd2c30f6 100644 --- a/src/loader/gtfs/trip.cc +++ b/src/loader/gtfs/trip.cc @@ -35,7 +35,7 @@ block::rule_services(trip_data& trips) { auto const is_empty = trips.data_[t].stop_seq_.empty(); if (is_empty) { utl::log_error("loader.gtfs.trip", "trip \"{}\": no stop times", - trips.data_[t].id_); + trips.data_[t].id_); } return is_empty; }); @@ -331,16 +331,16 @@ trip_data read_trips( auto const traffic_days_it = services.find(t.service_id_->view()); if (traffic_days_it == end(services)) { utl::log_error("loader.gtfs.trip", - R"(trip "{}": service_id "{}" not found)", t.trip_id_->view(), - t.service_id_->view()); + R"(trip "{}": service_id "{}" not found)", + t.trip_id_->view(), t.service_id_->view()); return; } auto const route_it = routes.find(t.route_id_->view()); if (route_it == end(routes)) { utl::log_error("loader.gtfs.trip", - R"(trip "{}": route_id "{}" not found)", t.trip_id_->view(), - t.route_id_->view()); + R"(trip "{}": route_id "{}" not found)", + t.trip_id_->view(), t.route_id_->view()); return; } @@ -402,7 +402,8 @@ void read_frequencies(trip_data& trips, std::string_view file_content) { auto const t = freq.trip_id_->trim().view(); auto const trip_it = trips.trips_.find(t); if (trip_it == end(trips.trips_)) { - utl::log_error("loader.gtfs.frequencies", + utl::log_error( + "loader.gtfs.frequencies", "frequencies.txt: skipping frequency (trip \"{}\" not found)", t); return; @@ -411,7 +412,8 @@ void read_frequencies(trip_data& trips, std::string_view file_content) { auto const headway_secs_str = *freq.headway_secs_; auto const headway_secs = parse(headway_secs_str, -1); if (headway_secs == -1) { - utl::log_error("loader.gtfs.frequencies", + utl::log_error( + "loader.gtfs.frequencies", R"(frequencies.txt: skipping frequency (invalid headway secs "{}"))", headway_secs_str.view()); return; diff --git a/src/loader/hrd/load_timetable.cc b/src/loader/hrd/load_timetable.cc index 36f6a98be..75c52de57 100644 --- a/src/loader/hrd/load_timetable.cc +++ b/src/loader/hrd/load_timetable.cc @@ -7,6 +7,7 @@ #include "utl/enumerate.h" #include "utl/helpers/algorithm.h" +#include "utl/logging.h" #include "utl/pipes.h" #include "utl/progress_tracker.h" @@ -26,9 +27,9 @@ bool applicable(config const& c, dir const& d) { auto const exists = d.exists(path); if (!exists) { utl::log_info("loader.hrd", - "input={}, missing file for config {}: {}", - d.path().generic_string(), c.version_.view(), - path.generic_string()); + "input={}, missing file for config {}: {}", + d.path().generic_string(), c.version_.view(), + path.generic_string()); } return exists; }); @@ -92,8 +93,7 @@ void load_timetable(source_idx_t const src, continue; } - utl::log_info("loader.hrd.services", "loading {}", - path.generic_string()); + utl::log_info("loader.hrd.services", "loading {}", path.generic_string()); auto const file = d.get_file(path); sb.add_services( c, relative(path, c.fplan_).string().c_str(), file.data(), diff --git a/src/loader/hrd/service/service_builder.cc b/src/loader/hrd/service/service_builder.cc index 849df4221..a1fedd77d 100644 --- a/src/loader/hrd/service/service_builder.cc +++ b/src/loader/hrd/service/service_builder.cc @@ -4,6 +4,7 @@ #include "utl/erase_duplicates.h" #include "utl/get_or_create.h" #include "utl/helpers/algorithm.h" +#include "utl/logging.h" #include "nigiri/loader/get_index.h" #include "nigiri/loader/hrd/service/read_services.h" @@ -217,8 +218,8 @@ void service_builder::write_services(source_idx_t const src) { .stop_seq_numbers_ = stop_seq_numbers_, .route_colors_ = route_colors_}); } catch (std::exception const& e) { - utl::log_error("loader.hrd.service", - "unable to load service {}: {}", ref.origin_, e.what()); + utl::log_error("loader.hrd.service", "unable to load service {}: {}", + ref.origin_, e.what()); continue; } } diff --git a/src/loader/hrd/stamm/attribute.cc b/src/loader/hrd/stamm/attribute.cc index 029e5a269..e2f2949d9 100644 --- a/src/loader/hrd/stamm/attribute.cc +++ b/src/loader/hrd/stamm/attribute.cc @@ -22,7 +22,7 @@ attribute_map_t parse_attributes(config const& c, return; } else if (line.len < 13 || (is_multiple_spaces(line) && line.len < 22)) { utl::log_error("loader.hrd.attribute", - "invalid attribute line - skipping {}", line_number); + "invalid attribute line - skipping {}", line_number); return; } diff --git a/src/loader/hrd/stamm/category.cc b/src/loader/hrd/stamm/category.cc index 7095bfac9..b69945d9a 100644 --- a/src/loader/hrd/stamm/category.cc +++ b/src/loader/hrd/stamm/category.cc @@ -1,8 +1,9 @@ #include "utl/parser/arg_parser.h" -#include "nigiri/clasz.h" #include "nigiri/loader/hrd/stamm/category.h" #include "nigiri/loader/hrd/util.h" +#include "nigiri/clasz.h" +#include "nigiri/scoped_timer.h" namespace nigiri::loader::hrd { diff --git a/src/loader/hrd/stamm/stamm.cc b/src/loader/hrd/stamm/stamm.cc index fa2af5020..0ce40731d 100644 --- a/src/loader/hrd/stamm/stamm.cc +++ b/src/loader/hrd/stamm/stamm.cc @@ -103,7 +103,7 @@ provider_idx_t stamm::resolve_provider(utl::cstr s) { auto const it = providers_.find(s.view()); if (it == end(providers_)) { utl::log_error("nigiri.loader.hrd.provider", - "creating new provider for missing {}", s.view()); + "creating new provider for missing {}", s.view()); auto const idx = provider_idx_t{tt_.providers_.size()}; tt_.providers_.emplace_back( provider{.short_name_ = s.view(), .long_name_ = s.view(), .url_ = ""}); diff --git a/src/loader/hrd/stamm/station.cc b/src/loader/hrd/stamm/station.cc index ec891128a..12bfd227c 100644 --- a/src/loader/hrd/stamm/station.cc +++ b/src/loader/hrd/stamm/station.cc @@ -17,7 +17,8 @@ void parse_station_names(config const& c, if (line.len == 0 || line[0] == '%') { return; } else if (line.len < 13) { - utl::log_error("loader.hrd.station.coordinates", + utl::log_error( + "loader.hrd.station.coordinates", "station name file unknown line format line={} content=\"{}\"", line_number, line.view()); return; @@ -44,7 +45,8 @@ void parse_station_coordinates(config const& c, if (line.len == 0 || line[0] == '%') { return; } else if (line.len < 30) { - utl::log_error("loader.hrd.station.coordinates", + utl::log_error( + "loader.hrd.station.coordinates", "station coordinate file unknown line format line={} content=\"{}\"", line_number, line.view()); return; @@ -61,46 +63,46 @@ void parse_equivilant_stations(config const& c, std::string_view file_content) { auto const is_5_20_26 = c.version_ == "hrd_5_20_26"; - utl::for_each_line_numbered( - file_content, [&](utl::cstr line, unsigned const line_number) { - if (line.length() < 16 || line[0] == '%' || line[0] == '*') { + utl::for_each_line_numbered(file_content, [&](utl::cstr line, + unsigned const line_number) { + if (line.length() < 16 || line[0] == '%' || line[0] == '*') { + return; + } + + if (line[7] == ':') { // equivalent stations + try { + auto const eva = + parse_eva_number(line.substr(c.meta_.meta_stations_.eva_)); + auto const station_it = stations.find(eva); + if (station_it == end(stations)) { + utl::log_error("loader.hrd.meta", "line {}: {} not found", + line_number, eva); return; } - - if (line[7] == ':') { // equivalent stations - try { - auto const eva = - parse_eva_number(line.substr(c.meta_.meta_stations_.eva_)); - auto const station_it = stations.find(eva); - if (station_it == end(stations)) { - utl::log_error("loader.hrd.meta", "line {}: {} not found", - line_number, eva); - return; - } - auto& station = station_it->second; - utl::for_each_token(line.substr(8), ' ', [&](utl::cstr token) { - if (token.empty() || (is_5_20_26 && token.starts_with("F"))) { - return; - } - if (token.starts_with("H") // Hauptmast - || token.starts_with("B") // Bahnhofstafel - || token.starts_with("V") // Virtueller Umstieg - || token.starts_with("S") // Start-Ziel-Aequivalenz - || token.starts_with("F") // Fußweg-Aequivalenz - ) { - return; - } - if (auto const meta = parse_eva_number(token); meta != 0) { - station.equivalent_.emplace(meta); - } - }); - } catch (std::exception const& e) { - utl::log_error("loader.hrd.equivalent", - "could not parse line {}: {}", line_number, e.what()); + auto& station = station_it->second; + utl::for_each_token(line.substr(8), ' ', [&](utl::cstr token) { + if (token.empty() || (is_5_20_26 && token.starts_with("F"))) { + return; } - } else { // footpaths - } - }); + if (token.starts_with("H") // Hauptmast + || token.starts_with("B") // Bahnhofstafel + || token.starts_with("V") // Virtueller Umstieg + || token.starts_with("S") // Start-Ziel-Aequivalenz + || token.starts_with("F") // Fußweg-Aequivalenz + ) { + return; + } + if (auto const meta = parse_eva_number(token); meta != 0) { + station.equivalent_.emplace(meta); + } + }); + } catch (std::exception const& e) { + utl::log_error("loader.hrd.equivalent", "could not parse line {}: {}", + line_number, e.what()); + } + } else { // footpaths + } + }); } void parse_footpaths(config const& c, @@ -133,8 +135,8 @@ void parse_footpaths(config const& c, parse_eva_number(line.substr(c.meta_.footpaths_.from_)); auto const from_it = stations.find(from_eva); if (from_it == end(stations)) { - utl::log_error("loader.hrd.footpath", - "footpath line={}: {} not found", line_number, to_idx(from_eva)); + utl::log_error("loader.hrd.footpath", "footpath line={}: {} not found", + line_number, to_idx(from_eva)); return; } auto& from = from_it->second; @@ -142,8 +144,8 @@ void parse_footpaths(config const& c, auto const to_eva = parse_eva_number(line.substr(c.meta_.footpaths_.to_)); auto const to_it = stations.find(to_eva); if (to_it == end(stations)) { - utl::log_error("loader.hrd.footpath", - "footpath line={}: {} not found", line_number, to_idx(to_eva)); + utl::log_error("loader.hrd.footpath", "footpath line={}: {} not found", + line_number, to_idx(to_eva)); return; } auto& to = to_it->second; diff --git a/src/loader/hrd/stamm/timezone.cc b/src/loader/hrd/stamm/timezone.cc index 30c32cf55..d27dc1364 100644 --- a/src/loader/hrd/stamm/timezone.cc +++ b/src/loader/hrd/stamm/timezone.cc @@ -66,8 +66,8 @@ timezone_map_t parse_timezones(config const& c, if (it != end(tz)) { tz[parse_eva_number(line.substr(c.tz_.type1_eva_))] = it->second; } else { - utl::log_error("loader.hrd.timezone", - "no timezone for eva number: {}", first_valid_eva_number); + utl::log_error("loader.hrd.timezone", "no timezone for eva number: {}", + first_valid_eva_number); } return; } diff --git a/src/loader/hrd/stamm/track.cc b/src/loader/hrd/stamm/track.cc index 460c99429..0ecec67a6 100644 --- a/src/loader/hrd/stamm/track.cc +++ b/src/loader/hrd/stamm/track.cc @@ -1,7 +1,7 @@ #include "utl/get_or_create.h" -#include "nigiri/loader/hrd/stamm/track.h" #include "nigiri/loader/hrd/stamm/stamm.h" +#include "nigiri/loader/hrd/stamm/track.h" #include "nigiri/loader/hrd/util.h" #include "nigiri/types.h" diff --git a/src/loader/load.cc b/src/loader/load.cc index 5699c5162..79888c92d 100644 --- a/src/loader/load.cc +++ b/src/loader/load.cc @@ -3,6 +3,7 @@ #include "fmt/std.h" #include "utl/enumerate.h" +#include "utl/logging.h" #include "nigiri/loader/dir.h" #include "nigiri/loader/gtfs/loader.h" diff --git a/src/query_generator/generator.cc b/src/query_generator/generator.cc index 69b91e1bd..37e7d2575 100644 --- a/src/query_generator/generator.cc +++ b/src/query_generator/generator.cc @@ -169,8 +169,8 @@ std::optional generator::random_query() { } utl::log_info("query_generator.random_pretrip", - "WARNING: failed to generate a valid query after {} attempts", - kMaxGenAttempts); + "WARNING: failed to generate a valid query after {} attempts", + kMaxGenAttempts); return std::nullopt; } @@ -198,7 +198,7 @@ location_idx_t generator::random_location() { return location_idx_t{locs_in_bbox[locs_in_bbox_d_(rng_)]}; } utl::log_info("query_generator.random_location", - "no locations in bounding box: using all locations instead"); + "no locations in bounding box: using all locations instead"); } return location_idx_t{location_d_(rng_)}; } diff --git a/src/routing/dijkstra.cc b/src/routing/dijkstra.cc index 53970886a..c618ae7c0 100644 --- a/src/routing/dijkstra.cc +++ b/src/routing/dijkstra.cc @@ -1,6 +1,7 @@ #include "nigiri/routing/dijkstra.h" #include "fmt/core.h" +#include "utl/logging.h" #include "utl/get_or_create.h" @@ -13,7 +14,7 @@ // #define NIGIRI_DIJKSTRA_TRACING #ifdef NIGIRI_DIJKSTRA_TRACING -#define trace(...) utl::debug(__VA_ARGS__) +#define trace(...) utl::log_debug("nigiri.routing.dijkstra", __VA_ARGS__) #else #define trace(...) #endif diff --git a/src/routing/ontrip_train.cc b/src/routing/ontrip_train.cc index 22a499faf..92df48d5a 100644 --- a/src/routing/ontrip_train.cc +++ b/src/routing/ontrip_train.cc @@ -1,5 +1,6 @@ #include "nigiri/routing/ontrip_train.h" +#include "utl/logging.h" #include "utl/verify.h" #include "nigiri/routing/query.h" @@ -12,7 +13,8 @@ constexpr auto const kTracing = true; template void trace(fmt::format_string fmt_str, Args... args) { if constexpr (kTracing) { - utl::debug(fmt_str, std::forward(args)...); + utl::log_debug("nigiri.routing.ontrip_train", fmt_str, + std::forward(args)...); } } diff --git a/src/routing/start_times.cc b/src/routing/start_times.cc index 3c50cdf77..2fbab8c0b 100644 --- a/src/routing/start_times.cc +++ b/src/routing/start_times.cc @@ -6,6 +6,7 @@ #include "utl/enumerate.h" #include "utl/equal_ranges_linear.h" #include "utl/get_or_create.h" +#include "utl/logging.h" #include "utl/overloaded.h" namespace nigiri::routing { @@ -32,7 +33,8 @@ duration_t get_duration(direction const search_dir, template void trace_start(char const* fmt_str, Args... args) { if constexpr (kTracing) { - utl::debug(fmt::runtime(fmt_str), std::forward(args)...); + utl::log_debug("nigiri.routing.start_times", fmt::runtime(fmt_str), + std::forward(args)...); } } diff --git a/src/rt/frun.cc b/src/rt/frun.cc index 896cee765..1591178a0 100644 --- a/src/rt/frun.cc +++ b/src/rt/frun.cc @@ -4,6 +4,7 @@ #include #include +#include "utl/logging.h" #include "utl/overloaded.h" #include "utl/verify.h" @@ -317,7 +318,7 @@ stop_idx_t frun::first_valid(stop_idx_t const from) const { } } utl::log_error("frun", "no first valid found: id={}, name={}, dbg={}", - fmt::streamed(id()), name(), fmt::streamed(dbg())); + fmt::streamed(id()), name(), fmt::streamed(dbg())); return stop_range_.to_; } @@ -331,7 +332,7 @@ stop_idx_t frun::last_valid() const { } } utl::log_error("frun", "no last valid found: id={}, name={}, dbg={}", - fmt::streamed(id()), name(), fmt::streamed(dbg())); + fmt::streamed(id()), name(), fmt::streamed(dbg())); return stop_range_.to_; } diff --git a/src/rt/gtfsrt_update.cc b/src/rt/gtfsrt_update.cc index 09bd215aa..0298c9695 100644 --- a/src/rt/gtfsrt_update.cc +++ b/src/rt/gtfsrt_update.cc @@ -214,7 +214,8 @@ void update_run( s.in_allowed()); } else { utl::log_error("gtfsrt.stop_assignment", - "stop assignment: src={}, stop_id=\"{}\" not found", src, new_id); + "stop assignment: src={}, stop_id=\"{}\" not found", + src, new_id); } } else { // Just reset in case a track change / skipped stop got reversed. @@ -308,8 +309,8 @@ statistics gtfsrt_update_msg(timetable const& tt, int& stat) { if (is_set) { utl::log_error("rt.gtfs.unsupported", - R"(ignoring unsupported "{}" field (tag={}, id={}))", field, tag, - entity.id()); + R"(ignoring unsupported "{}" field (tag={}, id={}))", + field, tag, entity.id()); ++stat; } }; @@ -320,7 +321,8 @@ statistics gtfsrt_update_msg(timetable const& tt, stats.unsupported_deleted_); if (!entity.has_trip_update()) { - utl::log_error("rt.gtfs.unsupported", + utl::log_error( + "rt.gtfs.unsupported", R"(unsupported: no "trip_update" field (tag={}, id={}), skipping message)", tag, entity.id()); ++stats.no_trip_update_; @@ -328,7 +330,8 @@ statistics gtfsrt_update_msg(timetable const& tt, } if (!entity.trip_update().has_trip()) { - utl::log_error("rt.gtfs.unsupported", + utl::log_error( + "rt.gtfs.unsupported", R"(unsupported: no "trip" field in "trip_update" field (tag={}, id={}), skipping message)", tag, entity.id()); ++stats.trip_update_without_trip_; @@ -336,7 +339,8 @@ statistics gtfsrt_update_msg(timetable const& tt, } if (!entity.trip_update().trip().has_trip_id()) { - utl::log_error("rt.gtfs.unsupported", + utl::log_error( + "rt.gtfs.unsupported", R"(unsupported: no "trip_id" field in "trip_update.trip" (tag={}, id={}), skipping message)", tag, entity.id()); ++stats.unsupported_no_trip_id_; @@ -347,7 +351,8 @@ statistics gtfsrt_update_msg(timetable const& tt, gtfsrt::TripDescriptor_ScheduleRelationship_SCHEDULED && entity.trip_update().trip().schedule_relationship() != gtfsrt::TripDescriptor_ScheduleRelationship_CANCELED) { - utl::log_error("rt.gtfs.unsupported", + utl::log_error( + "rt.gtfs.unsupported", "unsupported schedule relationship {} (tag={}, id={}), skipping " "message", TripDescriptor_ScheduleRelationship_Name( @@ -362,8 +367,8 @@ statistics gtfsrt_update_msg(timetable const& tt, auto [r, trip] = gtfsrt_resolve_run(today, tt, &rtt, src, td); if (!r.valid()) { - utl::log_error("rt.gtfs.resolve", "could not resolve (tag={}) {}", - tag, remove_nl(td.DebugString())); + utl::log_error("rt.gtfs.resolve", "could not resolve (tag={}) {}", tag, + remove_nl(td.DebugString())); span->AddEvent( "unresolved trip", { @@ -394,7 +399,8 @@ statistics gtfsrt_update_msg(timetable const& tt, ++stats.total_entities_success_; } catch (const std::exception& e) { ++stats.total_entities_fail_; - utl::log_error("rt.gtfs", + utl::log_error( + "rt.gtfs", "GTFS-RT error (tag={}): time={}, entity={}, message={}, error={}", tag, date::format("%T", message_time), entity.id(), remove_nl(entity.DebugString()), e.what()); @@ -420,7 +426,8 @@ statistics gtfsrt_update_buf(timetable const& tt, msg.ParseFromArray(reinterpret_cast(protobuf.data()), static_cast(protobuf.size())); if (!success) { - utl::log_error("rt.gtfs", + utl::log_error( + "rt.gtfs", "GTFS-RT error (tag={}): unable to parse protobuf message: {}", tag, protobuf.substr(0, std::min(protobuf.size(), size_t{1000U}))); return {.parser_error_ = true}; diff --git a/src/rt/vdv/vdv_update.cc b/src/rt/vdv/vdv_update.cc index 5567d7c12..198c91d81 100644 --- a/src/rt/vdv/vdv_update.cc +++ b/src/rt/vdv/vdv_update.cc @@ -8,6 +8,7 @@ #include "utl/enumerate.h" #include "utl/get_or_create.h" +#include "utl/logging.h" #include "utl/parser/arg_parser.h" #include "utl/verify.h" @@ -26,7 +27,7 @@ namespace nigiri::rt::vdv { // #define VDV_DEBUG #ifdef VDV_DEBUG -#define vdv_trace(...) utl::debug("nigiri.vdv_trace", __VA_ARGS__) +#define vdv_trace(...) utl::log_debug("nigiri.vdv_trace", __VA_ARGS__) #else #define vdv_trace(...) #endif @@ -89,8 +90,8 @@ std::optional updater::get_opt_time(pugi::xml_node const& node, try { return std::optional{parse_time_no_tz(xpath.node().child_value())}; } catch (std::exception const& e) { - utl::log_error("vdv_update.get_opt_time", - "{}, invalid time input: {}", e.what(), xpath.node().child_value()); + utl::log_error("vdv_update.get_opt_time", "{}, invalid time input: {}", + e.what(), xpath.node().child_value()); } } return std::nullopt; diff --git a/src/scoped_timer.cc b/src/scoped_timer.cc index 2c95134cf..435bbdad2 100644 --- a/src/scoped_timer.cc +++ b/src/scoped_timer.cc @@ -1,5 +1,7 @@ #include "utl/logging.h" +#include "nigiri/scoped_timer.h" + namespace nigiri { scoped_timer::scoped_timer(std::string name) @@ -13,8 +15,7 @@ scoped_timer::~scoped_timer() { auto const t = static_cast(duration_cast(stop - start_).count()) / 1000.0; - utl::log_info(name_.c_str(), "finished {} {}ms", std::string_view{name_}, - t); + utl::log_info(name_.c_str(), "finished {} {}ms", std::string_view{name_}, t); } } // namespace nigiri