OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
logging.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 VTT Technical Research Centre of Finland Ltd
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4#pragma once
5
13#include <iosfwd>
14#include <string>
15#include <string_view>
16
17namespace pfc {
18
22enum class LogLevel { Debug = 0, Info = 1, Warning = 2, Error = 3 };
23
29struct Logger {
30 const LogLevel m_min_level;
31 const int m_rank; // MPI rank (or -1 if unknown)
32};
33
40void log(const Logger &logger, LogLevel level, std::string_view message);
41
45inline void log_error(const Logger &lg, std::string_view msg) {
46 log(lg, LogLevel::Error, msg);
47}
48inline void log_warning(const Logger &lg, std::string_view msg) {
49 log(lg, LogLevel::Warning, msg);
50}
51inline void log_info(const Logger &lg, std::string_view msg) {
52 log(lg, LogLevel::Info, msg);
53}
54inline void log_debug(const Logger &lg, std::string_view msg) {
55 log(lg, LogLevel::Debug, msg);
56}
57
58} // namespace pfc
void log(const Logger &logger, LogLevel level, std::string_view message)
Write a log message if level >= logger.m_min_level.
void log_error(const Logger &lg, std::string_view msg)
Convenience helpers.
Definition logging.hpp:45
LogLevel
Log severity levels.
Definition logging.hpp:22
Lightweight logger configuration.
Definition logging.hpp:29
Represents the global simulation domain (the "world").
Definition world.hpp:91