Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
SourceLocation.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
16
18#include <fmt/core.h>
19#include <fmt/format.h>
20#include <fmt/printf.h>
21#include <fmt/ranges.h>
22
23std::string shambase::format_multiline(std::source_location loc) {
24 return fmt::format(
25 R"=(
26---- Source Location ----
27{}:{}:{}
28call = {}
29-------------------------
30)=",
31 loc.file_name(),
32 loc.line(),
33 loc.column(),
34 loc.function_name());
35}
36
37std::string shambase::format_multiline(std::source_location loc, const std::string &stacktrace) {
38 return fmt::format(
39 R"=(
40---- Source Location ----
41{}:{}:{}
42call = {}
43stacktrace :
44{}
45-------------------------
46)=",
47 loc.file_name(),
48 loc.line(),
49 loc.column(),
50 loc.function_name(),
51 stacktrace);
52}
53
54std::string shambase::format_one_line(std::source_location loc) {
55 return fmt::format("{}:{}:{}", loc.file_name(), loc.line(), loc.column());
56}
57
58std::string shambase::format_one_line_func(std::source_location loc) {
59 return fmt::format(
60 "{} ({}:{}:{})", loc.function_name(), loc.file_name(), loc.line(), loc.column());
61}
Source location utility.
std::string format_one_line_func(std::source_location loc)
format the location in a one liner with the function name displayed
std::string format_one_line(std::source_location loc)
format the location in a one liner
std::string format_multiline(std::source_location loc)
format the location in multiple lines