Build Packages / Create release (push) Successful in 17s
Build Packages / build:portable:macos-arm64:nocuda (push) Successful in 4m41s
Build Packages / HDF5 consumer tests (DIALS, XDS) (push) Successful in 20m49s
Build Packages / build:portable:windows-x86_64:nocuda (push) Successful in 13m6s
Build Packages / build:portable:windows-x86_64:cuda (push) Successful in 23m44s
Build Packages / build:rugnux:linux-aarch64:cuda (push) Successful in 7m28s
Build Packages / build:portable:linux-x86_64:nocuda (push) Successful in 11m50s
Build Packages / build:portable:linux-x86_64:cuda (push) Successful in 14m9s
Build Packages / build:jfjoch:rocky8:nocuda (push) Successful in 16m25s
Build Packages / build:jfjoch:ubuntu2204:nocuda (push) Successful in 15m42s
Build Packages / build:jfjoch:rocky9:nocuda (push) Successful in 20m50s
Build Packages / build:jfjoch:ubuntu2404:nocuda (push) Successful in 20m36s
Build Packages / build:jfjoch:rocky8:cuda-sls9 (push) Successful in 22m18s
Build Packages / build:jfjoch:rocky9:cuda-sls9 (push) Successful in 23m29s
Build Packages / Generate python client (push) Successful in 30s
Build Packages / Build documentation (push) Successful in 1m10s
Build Packages / build:jfjoch:rocky8:cuda (push) Successful in 21m38s
Build Packages / build:jfjoch:ubuntu2204:cuda (push) Successful in 17m8s
Build Packages / build:jfjoch:rocky9:cuda (push) Successful in 23m10s
Build Packages / build:jfjoch:ubuntu2404:cuda (push) Successful in 19m16s
Build Packages / Unit tests (push) Successful in 2h8m4s
Build Packages / Validation Battery (push) Successful in 40m53s
* Rugnux: Processes serial crystallography data from XFELs - SACLA (MPCCD), PAL-XFEL and European XFEL (CXI), LCLS (XTC) and SwissFEL Alvra (JUNGFRAU with a CrystFEL module geometry) - with several files or Jungfraujoch master files merged in one run (`rugnux *_master.h5`). * Rugnux: Stills processing takes a known unit cell and space group as a starting point, finds the beam centre (and, with a cell, the detector distance) from the images, detects the saturation level in other facilities' files and refines the placement of individual detector panels. * Rugnux: The stills report gives R_split and CC1/2 from frame half-sets, comparable with CrystFEL. * jfjoch_viewer: Opens the same XFEL file formats. * Validation: A stills battery checks Rugnux against deposited structures from SACLA, PAL-XFEL, LCLS, European XFEL and SwissFEL. * Rugnux: More reliable convergence of rotation scaling, and live molecular replacement starts as soon as the model is uploaded. * jfjoch_broker: Initialize clears the previous dataset's bearer tokens, image buffer and live Rugnux status, and a slow CUDA JIT cache is reported at start. Reviewed-on: #88 Co-authored-by: Filip Leonarski <filip.leonarski@psi.ch>
119 lines
3.7 KiB
C++
119 lines
3.7 KiB
C++
// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "spdlog/sinks/daily_file_sink.h"
|
|
#include "spdlog/sinks/stdout_color_sinks.h"
|
|
#include "spdlog/sinks/base_sink.h"
|
|
#include "spdlog/fmt/bin_to_hex.h"
|
|
|
|
#include <map>
|
|
|
|
#include "Logger.h"
|
|
#include "GitInfo.h"
|
|
|
|
#ifdef JFJOCH_USE_NVTX
|
|
#include <nvtx3/nvToolsExt.h>
|
|
|
|
uint64_t NvtxRangeStart(const std::string &name) {
|
|
return nvtxRangeStartA(name.c_str());
|
|
}
|
|
|
|
void NvtxRangeEnd(uint64_t id) {
|
|
nvtxRangeEnd(id);
|
|
}
|
|
#else
|
|
uint64_t NvtxRangeStart(const std::string &) {
|
|
return 0;
|
|
}
|
|
|
|
void NvtxRangeEnd(uint64_t) {}
|
|
#endif
|
|
|
|
namespace {
|
|
spdlog::sink_ptr routed_sink; // set once, at start-up, before any thread logs
|
|
std::map<std::string, spdlog::level::level_enum> service_levels; // the same
|
|
}
|
|
|
|
void Logger::RouteAll(spdlog::sink_ptr sink) {
|
|
routed_sink = std::move(sink);
|
|
}
|
|
|
|
void Logger::ServiceLevel(const std::string &service, spdlog::level::level_enum level) {
|
|
service_levels[service] = level;
|
|
}
|
|
|
|
Logger::Logger(const std::string &service_name, const std::string &file_name) {
|
|
if (routed_sink) {
|
|
spdlog_logger = std::make_shared<spdlog::logger>(service_name, routed_sink);
|
|
spdlog_logger->set_level(spdlog::level::debug);
|
|
return;
|
|
}
|
|
std::string variant = "";
|
|
#ifdef JFJOCH_USE_CUDA
|
|
variant += "C";
|
|
#endif
|
|
#ifdef JFJOCH_USE_FFTW
|
|
variant += "F";
|
|
#endif
|
|
std::vector<spdlog::sink_ptr> sinks;
|
|
|
|
sinks.push_back(std::make_shared<spdlog::sinks::stdout_color_sink_mt>());
|
|
if (!file_name.empty())
|
|
sinks.push_back(std::make_shared<spdlog::sinks::daily_file_sink_mt>(file_name, 23, 59));
|
|
|
|
spdlog_logger = std::make_shared<spdlog::logger>(service_name, std::begin(sinks), std::end(sinks));
|
|
if (const auto it = service_levels.find(service_name); it != service_levels.end())
|
|
spdlog_logger->set_level(it->second);
|
|
if (jfjoch_git_sha1().empty())
|
|
spdlog_logger->info("Version {} {}", jfjoch_version(), variant);
|
|
else
|
|
spdlog_logger->info("Version {} (git {} {}) {}",
|
|
jfjoch_version(),
|
|
jfjoch_git_sha1().substr(0, 6),
|
|
jfjoch_git_date(),
|
|
variant);
|
|
}
|
|
|
|
class LogBufferSink : public spdlog::sinks::base_sink<std::mutex> {
|
|
public:
|
|
struct Line {
|
|
spdlog::log_clock::time_point time;
|
|
spdlog::level::level_enum level;
|
|
std::string text;
|
|
};
|
|
std::vector<Line> lines;
|
|
protected:
|
|
void sink_it_(const spdlog::details::log_msg &msg) override {
|
|
lines.push_back({msg.time, msg.level, std::string(msg.payload.data(), msg.payload.size())});
|
|
}
|
|
void flush_() override {}
|
|
};
|
|
|
|
Logger::Logger(std::shared_ptr<LogBufferSink> sink) : buffer(std::move(sink)) {
|
|
spdlog_logger = std::make_shared<spdlog::logger>("buffer", buffer);
|
|
spdlog_logger->set_level(spdlog::level::trace); // the logger it is replayed into filters
|
|
}
|
|
|
|
Logger Logger::Buffered() {
|
|
return Logger(std::make_shared<LogBufferSink>());
|
|
}
|
|
|
|
// Called once the work that logged is finished, so nothing is still writing to the buffer. Each line
|
|
// keeps the time it was logged at, not the time of the replay, so a timestamped log still shows when
|
|
// the work happened.
|
|
void Logger::ReplayInto(Logger &to) const {
|
|
for (const auto &l : buffer->lines)
|
|
to.spdlog_logger->log(l.time, spdlog::source_loc{}, l.level, l.text);
|
|
}
|
|
|
|
void Logger::ErrorException(const std::exception &e) {
|
|
spdlog_logger->error(e.what());
|
|
}
|
|
|
|
Logger &Logger::Verbose(bool input) {
|
|
if (input)
|
|
spdlog_logger->set_level(spdlog::level::debug);
|
|
else
|
|
spdlog_logger->set_level(spdlog::level::info);
|
|
return *this;
|
|
} |