Skip to content

Commit

Permalink
Adopting utl::log()
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-C committed Jan 20, 2025
1 parent 0861ed9 commit bd4c201
Show file tree
Hide file tree
Showing 36 changed files with 135 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .pkg
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[utl]
[email protected]:motis-project/utl.git
branch=master
commit=368fdcb8326ced5bb151b60c09a07c2e5f09bf55
commit=492a0e3ae2d69d13b43141fff5d12b767d6155df
[miniz]
[email protected]:motis-project/miniz.git
branch=master
Expand Down
48 changes: 24 additions & 24 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
8143833587396253561
cista fabfc0cbcf07343a2e0c2def3009555b22f0ae46
PEGTL 1c1aa6e650e4d26f10fa398f148ec0cdc5f0808d
res b759b93316afeb529b6cb5b2548b24c41e382fb0
date ce88cc33b5551f66655614eeebb7c5b7189025fb
googletest 7b64fca6ea0833628d6f86255a81424365f7cc0c
fmt dc10f83be70ac2873d5f8d1ce317596f1fd318a2
utl 368fdcb8326ced5bb151b60c09a07c2e5f09bf55
oh d21c30f40e52a83d6dc09bcffd0067598b5ec069
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 73549ebca677fe6214202a1ab580362b4f80e653
doctest 70e8f76437b76dd5e9c0a2eb9b907df190ab71a0
geo cee17208dba98f5f3ddaf78d0bfff9c083557ba3
miniz 1edbdece9d71dc65c6ff405572ee37cbdcef7af4
libressl 24acd9e710fbe842e863572da9d738715fbc74b8
curl 39c8a51e8ee0ab7ea712886df79c068405a2e008
json 410c74782230daaa15054d6ee0975c0607091cb3
opentelemetry-proto 1624689398a3226c45994d70cb544a1e781dc032
abseil-cpp ba5240842d352b4b67a32092453a2fe5fe53a62e
protobuf df2dd518c68b882c9dce5346393f8c388108e733
opentelemetry-cpp 60770dc9dc63e3543fc87d605b2e88fd53d7a414
pugixml 60175e80e2f5e97e027ac78f7e14c5acc009ce50
unordered_dense 77e91016354e6d8cba24a86c5abb807de2534c02
wyhash 1e012b57fc2227a9e583a57e2eacb3da99816d99
11666447591127991742
cista fabfc0cbcf07343a2e0c2def3009555b22f0ae46
PEGTL 1c1aa6e650e4d26f10fa398f148ec0cdc5f0808d
res b759b93316afeb529b6cb5b2548b24c41e382fb0
date ce88cc33b5551f66655614eeebb7c5b7189025fb
googletest 7b64fca6ea0833628d6f86255a81424365f7cc0c
fmt dc10f83be70ac2873d5f8d1ce317596f1fd318a2
utl 69e700e03ae3d385304d754cf57877528bc591ef
oh d21c30f40e52a83d6dc09bcffd0067598b5ec069
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 73549ebca677fe6214202a1ab580362b4f80e653
doctest 70e8f76437b76dd5e9c0a2eb9b907df190ab71a0
geo cee17208dba98f5f3ddaf78d0bfff9c083557ba3
miniz 1edbdece9d71dc65c6ff405572ee37cbdcef7af4
libressl 24acd9e710fbe842e863572da9d738715fbc74b8
curl 39c8a51e8ee0ab7ea712886df79c068405a2e008
json 410c74782230daaa15054d6ee0975c0607091cb3
opentelemetry-proto 1624689398a3226c45994d70cb544a1e781dc032
abseil-cpp ba5240842d352b4b67a32092453a2fe5fe53a62e
protobuf df2dd518c68b882c9dce5346393f8c388108e733
opentelemetry-cpp 60770dc9dc63e3543fc87d605b2e88fd53d7a414
pugixml 60175e80e2f5e97e027ac78f7e14c5acc009ce50
unordered_dense 77e91016354e6d8cba24a86c5abb807de2534c02
wyhash 1e012b57fc2227a9e583a57e2eacb3da99816d99
2 changes: 1 addition & 1 deletion exe/benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include "utl/parallel_for.h"
#include "utl/progress_tracker.h"

#include "nigiri/logging.h"
#include "nigiri/qa/qa.h"
#include "nigiri/query_generator/generator.h"
#include "nigiri/routing/raptor/raptor.h"
#include "nigiri/routing/raptor_search.h"
#include "nigiri/routing/search.h"
#include "nigiri/scoped_timer.h"
#include "nigiri/timetable.h"
#include "nigiri/types.h"

Expand Down
8 changes: 4 additions & 4 deletions include/nigiri/footpath.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

#include "fmt/ostream.h"

#include "nigiri/footpath.h"
#include "utl/verify.h"

#include "cista/reflection/printable.h"

#include "nigiri/logging.h"
#include "nigiri/types.h"

namespace nigiri {
Expand Down Expand Up @@ -34,9 +34,9 @@ struct footpath {
kDurationBits,
"station index overflow");
if (duration > kMaxDuration) {
[[unlikely]] nigiri::log(log_lvl::error, "footpath",
"footpath overflow: {} > {} adjusted to {}",
duration, kMaxDuration, this->duration());
[[unlikely]] utl::error("footpath",
"footpath overflow: {} > {} adjusted to {}",
duration, kMaxDuration, this->duration());
}
}

Expand Down
1 change: 0 additions & 1 deletion include/nigiri/loader/build_lb_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "utl/pairwise.h"

#include "nigiri/logging.h"
#include "nigiri/timetable.h"
#include "nigiri/types.h"

Expand Down
72 changes: 0 additions & 72 deletions include/nigiri/logging.h

This file was deleted.

5 changes: 2 additions & 3 deletions include/nigiri/routing/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#include "utl/enumerate.h"
#include "utl/equal_ranges_linear.h"
#include "utl/erase_if.h"
#include "utl/logging.h"
#include "utl/timing.h"
#include "utl/to_vec.h"

#include "nigiri/for_each_meta.h"
#include "nigiri/get_otel_tracer.h"
#include "nigiri/logging.h"
#include "nigiri/routing/dijkstra.h"
#include "nigiri/routing/get_fastest_direct.h"
#include "nigiri/routing/interval_estimate.h"
Expand Down Expand Up @@ -420,8 +420,7 @@ struct search {
algo_.reconstruct(q_, j);
} catch (std::exception const& e) {
j.error_ = true;
log(log_lvl::error, "search", "reconstruct failed: {}",
e.what());
utl::log_error("search", "reconstruct failed: {}", e.what());
span->SetStatus(opentelemetry::trace::StatusCode::kError,
"exception");
span->AddEvent(
Expand Down
19 changes: 19 additions & 0 deletions include/nigiri/scoped_timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <chrono>

namespace nigiri {

struct scoped_timer final {
explicit scoped_timer(std::string name);
scoped_timer(scoped_timer const&) = delete;
scoped_timer(scoped_timer&&) = delete;
scoped_timer& operator=(scoped_timer const&) = delete;
scoped_timer& operator=(scoped_timer&&) = delete;
~scoped_timer();

std::string name_;
std::chrono::time_point<std::chrono::steady_clock> start_;
};

} // namespace nigiri
6 changes: 3 additions & 3 deletions include/nigiri/timetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "nigiri/common/interval.h"
#include "nigiri/footpath.h"
#include "nigiri/location.h"
#include "nigiri/logging.h"
#include "nigiri/scoped_timer.h"
#include "nigiri/stop.h"
#include "nigiri/td_footpath.h"
#include "nigiri/types.h"
Expand Down Expand Up @@ -52,8 +52,8 @@ struct timetable {
transfer_time_.emplace_back(l.transfer_time_);
parents_.emplace_back(l.parent_);
} else {
log(log_lvl::error, "timetable.register_location",
"duplicate station {}", l.id_);
utl::error("timetable.register_location", "duplicate station {}",
l.id_);
}

assert(names_.size() == next_idx + 1);
Expand Down
11 changes: 4 additions & 7 deletions src/abi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "nigiri/loader/gtfs/loader.h"
#include "nigiri/loader/hrd/loader.h"
#include "nigiri/loader/init_finish.h"
#include "nigiri/logging.h"
#include "nigiri/rt/create_rt_timetable.h"
#include "nigiri/rt/gtfsrt_update.h"
#include "nigiri/rt/rt_timetable.h"
Expand Down Expand Up @@ -61,8 +60,8 @@ nigiri_timetable_t* nigiri_load_from_dir(nigiri::loader::dir const& d,
auto const c =
utl::find_if(loaders, [&](auto&& l) { return l->applicable(d); });
utl::verify(c != end(loaders), "no loader applicable to the given file(s)");
nigiri::log(nigiri::log_lvl::info, "main",
"loading nigiri timetable with configuration {}", (*c)->name());
utl::info("main", "loading nigiri timetable with configuration {}",
(*c)->name());

auto t = new nigiri_timetable_t;
t->tt = std::make_unique<nigiri::timetable>();
Expand Down Expand Up @@ -267,11 +266,9 @@ void nigiri_update_with_rt_from_buf(const nigiri_timetable_t* t,
try {
nigiri::rt::gtfsrt_update_buf(*t->tt, *t->rtt, src, tag, protobuf);
} catch (std::exception const& e) {
nigiri::log(nigiri::log_lvl::error, "main",
"GTFS-RT update error (tag={}) {}", tag, e.what());
utl::error("main", "GTFS-RT update error (tag={}) {}", tag, e.what());
} catch (...) {
nigiri::log(nigiri::log_lvl::error, "main",
"Unknown GTFS-RT update error (tag={})", tag);
utl::error("main", "Unknown GTFS-RT update error (tag={})", tag);
}
t->rtt->reset_change_callback();
}
Expand Down
5 changes: 2 additions & 3 deletions src/clasz.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

#include "cista/hash.h"

#include "utl/logging.h"
#include "utl/verify.h"

#include "nigiri/logging.h"

namespace nigiri {

clasz get_clasz(std::string_view s) {
Expand Down Expand Up @@ -206,7 +205,7 @@ clasz get_clasz(std::string_view s) {
case hash("Elevator"): [[fallthrough]];
case hash("ASC"): return clasz::kOther;
default:
log(log_lvl::error, "loader.hrd.clasz", "cannot assign {}", s);
utl:log_error("loader.hrd.clasz", "cannot assign {}", s);
return clasz::kOther;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/loader/build_footpaths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "utl/equal_ranges_linear.h"
#include "utl/erase_duplicates.h"
#include "utl/erase_if.h"
#include "utl/logging.h"
#include "utl/pairwise.h"
#include "utl/parallel_for.h"
#include "utl/progress_tracker.h"
Expand All @@ -17,8 +18,8 @@
#include "nigiri/loader/merge_duplicates.h"
#include "nigiri/common/day_list.h"
#include "nigiri/constants.h"
#include "nigiri/logging.h"
#include "nigiri/routing/dijkstra.h"
#include "nigiri/scoped_timer.h"
#include "nigiri/rt/frun.h"
#include "nigiri/types.h"

Expand Down Expand Up @@ -301,7 +302,7 @@ void connect_components(timetable& tt,
std::max(static_cast<duration_t::rep>(duration.count()),
static_cast<duration_t::rep>(distance / kWalkSpeed / 60));
if (adjusted_int > std::numeric_limits<u8_minutes::rep>::max()) {
log(log_lvl::error, "loader.footpath.adjust",
utl::log_error("loader.footpath.adjust",
"too long after adjust: {}>256", adjusted_int);
}
adjusted = u8_minutes{adjusted_int};
Expand Down
4 changes: 2 additions & 2 deletions src/loader/dir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

#include "cista/mmap.h"

#include "utl/logging.h"
#include "utl/parser/cstr.h"
#include "utl/to_vec.h"
#include "utl/verify.h"

#include "nigiri/logging.h"
#include "wyhash.h"

template <>
Expand Down Expand Up @@ -73,7 +73,7 @@ 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} {
log(log_lvl::info, "loader.fs_dir", "loaded {}: {} bytes",
utl::log_info("loader.fs_dir", "loaded {}: {} bytes",
p.generic_string(), mmap_.size());
}
~mmap_content() final = default;
Expand Down
4 changes: 2 additions & 2 deletions src/loader/gtfs/load_timetable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#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"
Expand All @@ -30,8 +31,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/logging.h"
#include "nigiri/scoped_timer.h"
#include "nigiri/timetable.h"

namespace fs = std::filesystem;
Expand Down
5 changes: 3 additions & 2 deletions src/loader/gtfs/route.cc
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include "nigiri/loader/gtfs/route.h"

#include "utl/get_or_create.h"
#include "utl/logging.h"
#include "utl/parser/buf_reader.h"
#include "utl/parser/csv_range.h"
#include "utl/parser/line_range.h"
#include "utl/pipes/transform.h"
#include "utl/pipes/vec.h"
#include "utl/progress_tracker.h"

#include "nigiri/logging.h"
#include "nigiri/scoped_timer.h"
#include "nigiri/timetable.h"

namespace nigiri::loader::gtfs {
Expand Down Expand Up @@ -176,7 +177,7 @@ route_map_t read_routes(timetable& tt,
agencies.size() == 1U
? agencies.begin()->second
: utl::get_or_create(agencies, r.agency_id_->view(), [&]() {
log(log_lvl::error, "gtfs.route",
utl::log_error("gtfs.route",
"agency {} not found, using UNKNOWN with local "
"timezone",
r.agency_id_->view());
Expand Down
Loading

0 comments on commit bd4c201

Please sign in to comment.