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 21, 2025
1 parent 0861ed9 commit 595e7a9
Show file tree
Hide file tree
Showing 37 changed files with 116 additions and 179 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]
url=git@github.com:motis-project/utl.git
branch=master
commit=368fdcb8326ced5bb151b60c09a07c2e5f09bf55
commit=ecd49babfef266e66a003bb9f118b18f1e5e1ef
[miniz]
url=git@github.com:motis-project/miniz.git
branch=master
Expand Down
5 changes: 3 additions & 2 deletions .pkg.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
8143833587396253561
15278028716458998313
cista fabfc0cbcf07343a2e0c2def3009555b22f0ae46
PEGTL 1c1aa6e650e4d26f10fa398f148ec0cdc5f0808d
res b759b93316afeb529b6cb5b2548b24c41e382fb0
date ce88cc33b5551f66655614eeebb7c5b7189025fb
googletest 7b64fca6ea0833628d6f86255a81424365f7cc0c
docs 6f234581cab199d66d070e4de8a32ddba1967b38
fmt dc10f83be70ac2873d5f8d1ce317596f1fd318a2
utl 368fdcb8326ced5bb151b60c09a07c2e5f09bf55
utl 492a0e3ae2d69d13b43141fff5d12b767d6155df
oh d21c30f40e52a83d6dc09bcffd0067598b5ec069
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 73549ebca677fe6214202a1ab580362b4f80e653
Expand Down
Empty file modified .pkg.mutex
100644 → 100755
Empty file.
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::log_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::log_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::log_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
7 changes: 4 additions & 3 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 @@ -71,10 +71,11 @@ file fs_dir::get_file(std::filesystem::path const& p) const {
mmap_content(mmap_content&&) = delete;
mmap_content& operator=(mmap_content&&) = delete;
mmap_content& operator=(mmap_content const&) = delete;
auto const path = p.generic_string();
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",
p.generic_string(), mmap_.size());
utl::log_info("loader.fs_dir", "loaded {}: {} bytes",
path, mmap_.size());
}
~mmap_content() final = default;
std::string_view get() const final { return mmap_.view(); }
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
5 changes: 2 additions & 3 deletions src/loader/gtfs/services.cc
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#include "nigiri/loader/gtfs/services.h"

#include "utl/get_or_create.h"
#include "utl/progress_tracker.h"

#include "nigiri/logging.h"
#include "nigiri/loader/gtfs/services.h"
#include "nigiri/scoped_timer.h"

namespace nigiri::loader::gtfs {

Expand Down
1 change: 0 additions & 1 deletion src/loader/gtfs/shape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "utl/sort_by.h"

#include "nigiri/common/cached_lookup.h"
#include "nigiri/logging.h"
#include "nigiri/shapes_storage.h"

namespace nigiri::loader::gtfs {
Expand Down
Loading

0 comments on commit 595e7a9

Please sign in to comment.