Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopting utl::log() #165

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=2d8b992e23ecf7dcd0742420e92fac4a7c290d4e
[miniz]
[email protected]: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
9188511793150230166
cista fabfc0cbcf07343a2e0c2def3009555b22f0ae46
PEGTL 1c1aa6e650e4d26f10fa398f148ec0cdc5f0808d
res b759b93316afeb529b6cb5b2548b24c41e382fb0
date ce88cc33b5551f66655614eeebb7c5b7189025fb
googletest 7b64fca6ea0833628d6f86255a81424365f7cc0c
docs 75dc89a53e9c2d78574fc0ffda698e69f1682ed2
fmt dc10f83be70ac2873d5f8d1ce317596f1fd318a2
utl 368fdcb8326ced5bb151b60c09a07c2e5f09bf55
utl 2d8b992e23ecf7dcd0742420e92fac4a7c290d4e
oh d21c30f40e52a83d6dc09bcffd0067598b5ec069
zlib-ng 68ab3e2d80253ec5dc3c83691d9ff70477b32cd3
boost 73549ebca677fe6214202a1ab580362b4f80e653
Expand Down
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 "utl/logging.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
8 changes: 6 additions & 2 deletions include/nigiri/loader/hrd/service/expand_local_to_utc.h
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -55,7 +57,8 @@ std::optional<duration_t> build_utc_time_seq(
stop_timezones.front(), day, local_times.front(), true);

if (!first_valid) {
log(log_lvl::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;
Expand All @@ -67,7 +70,8 @@ std::optional<duration_t> 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) {
log(log_lvl::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);
Expand Down
11 changes: 6 additions & 5 deletions include/nigiri/loader/hrd/service/read_services.h
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -55,16 +56,16 @@ void parse_services(config const& c,
}

if (!spec.valid()) {
log(log_lvl::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) {
log(log_lvl::error, "loader.hrd.service.expand",
"unable to build service at {}:{}: {}", filename, line_number,
e.what());
utl::log_error("loader.hrd.service.expand",
"unable to build service at {}:{}: {}", filename,
line_number, e.what());
}
}

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why nigiri::scoped_timer if there's utl::scoped_timer?


#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
7 changes: 4 additions & 3 deletions include/nigiri/timetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -16,7 +17,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 +53,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
30 changes: 13 additions & 17 deletions src/abi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,33 @@
#include <memory>
#include <vector>

#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/logging.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 {
Expand Down Expand Up @@ -61,8 +59,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 +265,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::log_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::log_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
Loading
Loading