Files
Jungfraujoch/common/Logger.h
leonarski_f cd70fa0eca
Some checks failed
Build Packages / build:rpm (rocky8_nocuda) (push) Failing after 10m33s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Failing after 13m28s
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Failing after 14m11s
Build Packages / build:rpm (rocky9_nocuda) (push) Failing after 15m22s
Build Packages / Generate python client (push) Successful in 1m12s
Build Packages / Build documentation (push) Successful in 24s
Build Packages / Create release (push) Has been skipped
Build Packages / build:rpm (rocky9) (push) Failing after 16m31s
Build Packages / build:rpm (rocky8_sls9) (push) Failing after 17m13s
Build Packages / build:rpm (rocky8) (push) Failing after 17m15s
Build Packages / build:rpm (rocky9_sls9) (push) Failing after 17m27s
Build Packages / build:rpm (ubuntu2204) (push) Failing after 10m15s
Build Packages / build:rpm (ubuntu2404) (push) Failing after 8m40s
Build Packages / Unit tests (push) Has been cancelled
Move spdlog to downloaded dependency
2026-03-18 20:30:48 +01:00

60 lines
1.7 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#ifndef JUNGFRAUJOCH_LOGGER_H
#define JUNGFRAUJOCH_LOGGER_H
#include <cstdint>
#include <chrono>
#include <iostream>
#include <mutex>
#include <memory>
#include <spdlog/spdlog.h>
#include <spdlog/fmt/fmt.h>
namespace spdlog {
class logger;
}
class Logger {
mutable std::mutex m;
std::shared_ptr<spdlog::logger> spdlog_logger;
std::string service;
std::string hostname;
public:
Logger(const std::string &service_name, const std::string &file_name = "");
void ErrorException(const std::exception &e);
void Info(const std::string& msg) { spdlog_logger->info(msg); }
void Warning(const std::string& msg) { spdlog_logger->warn(msg); }
void Error(const std::string& msg) { spdlog_logger->error(msg); }
void Debug(const std::string& msg) { spdlog_logger->debug(msg); }
template<typename... Args>
void Info(fmt::format_string<Args...> fmt, Args &&... args) {
spdlog_logger->info(fmt, std::forward<Args>(args)...);
}
template<typename... Args>
void Error(fmt::format_string<Args...> fmt, Args &&... args) {
spdlog_logger->error(fmt, std::forward<Args>(args)...);
}
template<typename... Args>
void Debug(fmt::format_string<Args...> fmt, Args &&... args) {
spdlog_logger->debug(fmt, std::forward<Args>(args)...);
}
template<typename... Args>
void Warning(fmt::format_string<Args...> fmt, Args &&... args) {
spdlog_logger->warn(fmt, std::forward<Args>(args)...);
}
Logger& Verbose(bool input);
};
#endif //JUNGFRAUJOCH_LOGGER_H