Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
logs.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
20#include "shamcomm/logs.hpp"
22#include <cmath>
23
24namespace shamcomm::logs {
25
27 // log level declared printer
29
31#define IsActivePrint(_name, StructREF) _name##_ln("xxx", "xxx", "(", "logger::" #_name, ")");
32
34 raw_ln("log status : ");
35 if (get_loglevel() == i8_max) {
36 raw_ln("If you've seen spam in your life i can garantee you, this is worst");
37 }
38
39 raw_ln(shambase::format(" - Loglevel: {}, enabled log types :", u32(get_loglevel())));
40
41// logger::raw_ln(terminal_effects::faint + "----------------------" + terminal_effects::reset);
42
44#define X IsActivePrint
46#undef X
47 // logger::raw_ln(terminal_effects::faint + "----------------------" +
48 // terminal_effects::reset);
49 }
50
51#undef IsActivePrint
52
54 // Code init done
56
58
59 // start allow utf-8
60 auto lines = std::vector<std::string>{
61 // Someone that coded too much here
62 "Now it's time to " + shambase::term_colors::col8b_cyan()
64 "Shamrock rolls - no time for moss.", // Rolling stone gathers no moss.
65 "Shamrock's live - go with the flow.",
66 "Shamrock - as solid as a rock.",
67 "Shamrock's stable and steady as a rock.",
68 "Shamrock initialized - no cracks in this rock.",
69 "Shamrock is ready to eat cheese (melted) and bread.",
70 "Are you sure you want to work today?",
71 "No holidays for the Shamrock ... (yeah, this was a PhD at some point)",
72 "-[--->+<]>--.>+[----->+++<]>+.-------.++++++++++++.+++++.---.------------.++++++++.",
73 "CPU hours to burn? We don't do such thing here.",
74 "Are you burning GPUs or CPUs today?",
75 R"=(
76While you wait for this simulation to run, give that cat a hug!
77
78 |\__/,| (`\
79 _.|o o |_ ) )
80-(((---(((--------
81 )=",
82
83 // Someone that started on oumuamua
84 "Shamrock your way to a brighter day!",
85 "Node hours to burn? Leaf it to me.",
86 "Ready for some shamazing simulations?",
87 "SHAMROCKがきれいですね ~",
88 "シャムロック",
89
90 // by the coagulator
91 "We're not here to make seagulls laugh",
92
93 // in places
94 "日本でも使ている", // used in japan
95 "Pretty sure Aussies use that too, mate."};
96 // end allow utf-8
97
98 auto get_sentence = [&]() {
100 u64 idx = static_cast<u64>(std::floor(
101 t * 2503'09713 // you wont guess what this stands for
102 ))
103 % lines.size();
104 return lines[idx];
105 };
106
107 if (shamcomm::world_rank() == 0) {
110 " - Code init:",
112 + ".",
113 get_sentence());
115 }
116 }
117
118} // namespace shamcomm::logs
119
120std::string LogLevel_DebugAlloc::reformat(const std::string &in, std::string module_name) {
122}
123
124std::string LogLevel_DebugMPI::reformat(const std::string &in, std::string module_name) {
126}
127
128std::string LogLevel_DebugSYCL::reformat(const std::string &in, std::string module_name) {
131}
132
133std::string LogLevel_Debug::reformat(const std::string &in, std::string module_name) {
135}
136
137std::string LogLevel_Info::reformat(const std::string &in, std::string module_name) {
138 return logger::reformat_all(shambase::term_colors::col8b_cyan(), "Info", module_name, in);
139}
140
141std::string LogLevel_Normal::reformat(const std::string &in, std::string module_name) {
143}
144
145std::string LogLevel_Warning::reformat(const std::string &in, std::string module_name) {
147}
148
149std::string LogLevel_Error::reformat(const std::string &in, std::string module_name) {
151}
double f64
Alias for double.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
std::string reformat_all(const std::string &color, const char *name, const std::string &module_name, const std::string &content)
Format a log message with all the information.
i8 get_loglevel()
Get the current global log level.
Definition loglevel.hpp:52
std::string reformat_simple(const std::string &color, const char *name, const std::string &module_name, const std::string &content)
Format a log message with the minimum information.
i32 world_rank()
Gives the rank of the current process in the MPI communicator.
Definition worldInfo.cpp:40
constexpr i8 i8_max
i8 max value
void print_active_level()
Prints the active log levels.
Definition logs.cpp:33
void code_init_done_log()
Indicates that the code initialization is complete through various means ;).
Definition logs.cpp:57
void raw_ln(Types... var2)
Prints a log message with multiple arguments followed by a newline.
Definition logs.hpp:90
void print_faint_row()
Prints a faint separator line to the log.
Definition logs.hpp:100
#define LIST_LEVEL
X-macro for log level definition.
Definition logs.hpp:43
This file contains the definition for the stacktrace related functionality.
f64 get_wtime()
Returns the current wall clock time in seconds.
static constexpr const char * level_name
Log level name.
Definition loglevels.hpp:29
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for debugging memory allocation.
Definition logs.cpp:120
static constexpr const char * level_name
Log level name.
Definition loglevels.hpp:67
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for debugging MPI operations.
Definition logs.cpp:124
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for debugging SYCL operations.
Definition logs.cpp:128
static constexpr const char * level_name
Log level name.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for debugging general operations.
Definition logs.cpp:133
static constexpr const char * level_name
Log level name.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for error messages.
Definition logs.cpp:149
static constexpr const char * level_name
Log level name.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for informational messages.
Definition logs.cpp:137
static constexpr const char * level_name
Log level name.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for normal messages.
Definition logs.cpp:141
static constexpr const char * level_name
Log level name.
static std::string reformat(const std::string &in, std::string module_name)
Log formatter function for warning messages.
Definition logs.cpp:145
const std::string reset()
Get the reset terminal escape char.
const std::string col8b_yellow()
Get the yellow terminal escape char.
const std::string col8b_magenta()
Get the magenta (pink) terminal escape char.
const std::string empty()
Get the empty terminal escape.
const std::string blink()
Get the blink terminal escape char.
const std::string col8b_green()
Get the green terminal escape char.
const std::string col8b_blue()
Get the blue terminal escape char.
const std::string col8b_cyan()
Get the cyan terminal escape char.
const std::string col8b_red()
Get the red terminal escape char.
Functions related to the MPI communicator.