Loading...
Searching...
No Matches
q3::log Namespace Reference

Functions

void apply_verbosity (const std::string &verbosity, const std::string &explicit_log_level)
 
spdlog::level::level_enum & baseline_logger_level ()
 
std::shared_ptr< spdlog::sinks::stdout_color_sink_mt > & console_sink ()
 
template<typename... Args>
void debug (spdlog::format_string_t< Args... > fmt, Args &&... args)
 
template<typename... Args>
void error (spdlog::format_string_t< Args... > fmt, Args &&... args)
 
void fatal (const std::string &message)
 
void flush ()
 
template<typename... Args>
void info (spdlog::format_string_t< Args... > fmt, Args &&... args)
 
void init (const std::string &log_file="")
 
void init_mpi (const std::string &log_file="")
 
void section (const std::string &title)
 
void set_console_level_unless_silenced (spdlog::level::level_enum level)
 
void set_level (const std::string &level)
 Set log level: "trace", "debug", "info", "warn", "error", "off".
 
void silence ()
 
template<typename... Args>
void trace (spdlog::format_string_t< Args... > fmt, Args &&... args)
 
template<typename... Args>
void warn (spdlog::format_string_t< Args... > fmt, Args &&... args)
 

Function Documentation

◆ apply_verbosity()

void q3::log::apply_verbosity ( const std::string &  verbosity,
const std::string &  explicit_log_level 
)
inline

Apply an input deck's control.verbosity to the log level.

explicit_log_level is whatever –log-level was given, empty when it was not. An explicit flag always wins: it is the more specific request, and a deck carried from machine to machine must not talk over what the command line asked for.

"high" opens up the per-iteration and per-phase diagnostics, which are logged at debug. "default" puts the level back where init() left it rather than assuming info, so that a log file keeps receiving those records and so that one in-process run cannot inherit the previous deck's verbosity.

Definition at line 113 of file logger.hpp.

References baseline_logger_level(), set_console_level_unless_silenced(), and set_level().

Referenced by q3::bindings::SCFSolver::SCFSolver(), q3::cli::read_input(), q3::bindings::run_nscf(), and q3::bindings::run_scf().

◆ baseline_logger_level()

spdlog::level::level_enum & q3::log::baseline_logger_level ( )
inline

The level init() left the logger at, so a later change can be undone.

Not simply info: a run that asked for a log file deliberately drops the logger to debug so the file sink sees records the console does not, and restoring info instead would empty that file. The console sink needs no such memory – init() always pins it at info.

Definition at line 40 of file logger.hpp.

Referenced by apply_verbosity(), and init().

◆ console_sink()

std::shared_ptr< spdlog::sinks::stdout_color_sink_mt > & q3::log::console_sink ( )
inline

Initialize the logger. Call once at startup.

Definition at line 27 of file logger.hpp.

Referenced by init(), set_console_level_unless_silenced(), and silence().

◆ debug()

◆ error()

◆ fatal()

void q3::log::fatal ( const std::string &  message)
inline

Report a fatal error on stderr, whatever the current log level.

error() routes through spdlog, and silence() takes the console sink off – which means that on a silenced rank a fatal error still reaches that rank's log file, if it has one, but never the console the user is watching. A process about to die owes its user a reason on the console whether or not a log file was asked for, so this bypasses spdlog and writes straight to stderr, flushing before it returns: MPI_Abort neither unwinds nor flushes, and a rank that exits nonzero takes its peers down with it, so anything still sitting in a buffer at that point is never seen.

Definition at line 166 of file logger.hpp.

Referenced by main().

◆ flush()

void q3::log::flush ( )
inline

Push every buffered record to its sink.

Needed before any exit that skips destructors – MPI_Abort, std::_Exit – because spdlog buffers, and a process killed with records still in the buffer loses them. The message being lost is invariably the one explaining why the process is exiting, which is the one worth keeping.

Definition at line 133 of file logger.hpp.

◆ info()

template<typename... Args>
void q3::log::info ( spdlog::format_string_t< Args... >  fmt,
Args &&...  args 
)
inline

Definition at line 183 of file logger.hpp.

Referenced by q3::LocalThomasFermiPreconditioner::apply(), q3::assemble_total_stress_and_log(), q3::paw_one_center::PawOneCenterTerms::build(), q3::PlanewaveChargeDensitySymmetrizer::build_shells(), q3::internal::build_wannier_interface_record(), q3::capture_interpolation_record(), q3::MaximallyLocalizedGaugeChoice::choose(), q3::PawPlanewavePseudopotentialKohnShamSCFIterator::construct_density_from_states(), q3::create_gauge_choice(), q3::create_kohn_sham_iterator(), q3::export_and_record_mean_field(), q3::Wannier90Exporter::export_to_directory(), q3::SymmetryAnalyzer::find_spacegroup(), q3::functional_from_pseudopotentials(), q3::UltrasoftPlanewaveBasis::init_ultrasoft(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_charge_density(), q3::NormConservingPlanewaveWavefunctionInitializer::initialize_interpolation_table(), q3::PlanewaveKohnShamSCFIterator::initialize_representation(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_single_particle_states(), q3::PlanewaveKohnShamSCFIterator::initiate_mixer(), q3::load_pseudopotentials(), q3::KohnShamSCFIterator::log_iteration_energy(), q3::PlanewavePseudopotentialKohnShamSCFIterator::log_pseudopotential_summary(), q3::ProfilingCounters::log_resident_checkpoint(), q3::PlanewaveEffectivePotential::log_summary(), main(), q3::BroydenMixer::mix_in_reciprocal_space(), q3::PawPlanewavePseudopotentialKohnShamSCFIterator::on_charge_density_initialized(), q3::QEInputParser::parse(), q3::parse_input(), q3::KohnShamSCFIterator::perform_iteration(), q3::UltrasoftPlanewaveBasis::precompute_q_functions_g(), q3::KPointsGrid::pretty_print(), q3::ProfilingCounters::print_memory_summary(), q3::cli::print_timestamped_banner(), q3::cli::print_version(), q3::UltrasoftUPFv1Reader::read(), q3::cli::read_input(), q3::SymmetryAnalyzer::reduce_kpoints(), q3::SymmetryAnalyzer::reduce_kpoints_internal(), q3::KohnShamSCFIterator::report_convergence(), q3::PawPlanewavePseudopotentialKohnShamSCFIterator::report_convergence_details(), q3::PlanewaveKohnShamSCFReporter::report_first_iteration(), q3::KohnShamSCFIterator::report_non_convergence(), report_resolved_input(), q3::PlanewaveKohnShamSCFReporter::report_setup_summary(), q3::SCFIterator::run(), q3::SubspaceDisentangler::run(), q3::VolumetricCommand::run(), q3::NonSelfConsistentFieldFlavor::run_calculation(), q3::SelfConsistentFieldFlavor::run_calculation(), q3::VerificationFlavor::run_calculation(), q3::cli::run_gpu_entry_point(), section(), q3::GPUPlanewaveHamiltonianApplicator::set_use_mixed_precision(), q3::PlanewavePseudopotentialKohnShamSCFIterator::setup_hubbard(), q3::cli::validate_gpu_blas(), q3::cli::validate_gpu_device_backend(), q3::cli::validate_gpu_eigensolver(), q3::write_and_export_interpolation_record(), q3::PlanewavePseudopotentialKohnShamSCFIterator::write_checkpoints(), q3::write_json_file(), q3::BerkeleyGWChargeDensityFile::write_to_file(), q3::BerkeleyGWExchangeCorrelationFile::write_to_file(), q3::BerkeleyGWExchangeCorrelationPotentialFile::write_to_file(), q3::BerkeleyGWKleinmanBylanderProjectorFile::write_to_file(), q3::BerkeleyGWSelfConsistentPotentialFile::write_to_file(), q3::BerkeleyGWWavefunctionFile::write_to_file(), q3::QEPlanewaveKohnShamChargeDensityCheckpoint::write_to_file(), and q3::QEPlanewaveKohnShamWavefunctionCheckpoint::write_to_file().

◆ init()

void q3::log::init ( const std::string &  log_file = "")
inline

The file is a second sink on the same logger, not a logger of its own. It used to be the latter – registered under its own name and never written to, because every log:: call goes to the default logger – so a requested log file was reliably created and reliably empty.

It is given a lower threshold than the console on purpose: a file is asked for when the console has already proved too terse, so it carries debug records the console drops. That is also why the logger's own threshold moves down with it – a logger filters before its sinks do, so leaving it at info would discard those records before the file sink ever saw them.

Definition at line 59 of file logger.hpp.

References baseline_logger_level(), and console_sink().

Referenced by init_mpi(), main(), and q3::cli::run_gpu_entry_point().

◆ init_mpi()

void q3::log::init_mpi ( const std::string &  log_file = "")
inline

Initialize the logger for MPI runs.

Calls the serial init() then silences stdout on all non-zero ranks. Each rank still writes to its own log file if log_file is provided.

Parameters
log_fileOptional base path for per-rank file sinks. Rank 0 writes to log_file; rank N writes to log_file.N.

Silence console output on all non-root ranks via the logger wrapper — no direct spdlog access outside io/logger.hpp.

Definition at line 29 of file logger_mpi.hpp.

References init(), and silence().

Referenced by q3::create_scf_iterator_mpi(), and main().

◆ section()

void q3::log::section ( const std::string &  title)
inline

A blank line, then a section title at the common margin, underlined.

Every block-level heading a run prints goes through here, so the margin and the separation between blocks are decided once rather than at each print site – which is how the output came to carry three competing left margins and three header styles. The title text itself is passed through unchanged, because several of these headings are what the validation suite's stdout parsers key on.

Definition at line 206 of file logger.hpp.

References info().

Referenced by q3::assemble_total_stress_and_log(), and q3::SCFIterator::initialize().

◆ set_console_level_unless_silenced()

void q3::log::set_console_level_unless_silenced ( spdlog::level::level_enum  level)
inline

Move the console sink's own threshold, unless this process was silenced.

The sink filters after the logger does, so a logger-level change on its own never reaches the terminal. Moving the sink unconditionally would have the opposite fault: silence() takes it to off on a non-root MPI rank, and that decision must outlive any later level change.

Definition at line 53 of file logger.hpp.

References console_sink().

Referenced by apply_verbosity(), and set_level().

◆ set_level()

void q3::log::set_level ( const std::string &  level)
inline

Set log level: "trace", "debug", "info", "warn", "error", "off".

Definition at line 94 of file logger.hpp.

References set_console_level_unless_silenced().

Referenced by apply_verbosity(), main(), and q3::cli::run_gpu_entry_point().

◆ silence()

void q3::log::silence ( )
inline

Silence this process's console output (e.g. non-root MPI ranks).

Silences the console sink, not the logger. Setting the logger's own level to off would silence its file sink too, and the one thing a non-root rank has to be able to do is write its own log file – which is the entire reason init_mpi() gives each rank a numbered one. Falls back to the logger-wide setting only if init() has not run.

Definition at line 146 of file logger.hpp.

References console_sink().

Referenced by init_mpi().

◆ trace()

template<typename... Args>
void q3::log::trace ( spdlog::format_string_t< Args... >  fmt,
Args &&...  args 
)
inline

Definition at line 174 of file logger.hpp.

◆ warn()

template<typename... Args>
void q3::log::warn ( spdlog::format_string_t< Args... >  fmt,
Args &&...  args 
)
inline

Definition at line 187 of file logger.hpp.

Referenced by q3::PlanewaveKohnShamSCFIterator::build_kpoint_plane_wave_data(), q3::upf_utilities::check_atomic_wavefunction_norm(), q3::NormConservingPlanewaveStressTensorCalculator::compute(), q3::MartynaTuckermanCorrectionCalculator::compute(), q3::create_kohn_sham_iterator(), q3::GPUPlanewaveSubspaceManager::diagonalize_subspace(), q3::SerialPlanewaveSubspaceManager::diagonalize_subspace(), q3::export_and_record_mean_field(), q3::Wannier90Exporter::export_to_directory(), q3::BerkeleyGWExporter::export_to_directory(), q3::SymmetryAnalyzer::find_spacegroup(), q3::SymmetryAnalyzer::get_symmetry_operations(), q3::PlanewavePseudopotentialKohnShamSCFIterator::initialize_representation(), q3::BroydenMixer::mix_in_reciprocal_space(), q3::AndersonMixer::mix_one_component(), q3::SymmetryAnalyzer::reduce_kpoints(), q3::KohnShamSCFIterator::report_non_convergence(), q3::PlanewavePseudopotentialKohnShamSCFIterator::report_unconverged_solve(), q3::PlanewaveKohnShamSCFIterator::resolve_number_of_bands(), q3::NonSelfConsistentFieldFlavor::run_calculation(), q3::SelfConsistentFieldFlavor::run_calculation(), q3::cli::run_gpu_entry_point(), q3::PlanewaveDavidsonDiagonalizer::solve(), q3::PlanewaveKohnShamSCFIterator::warn_if_total_charge_deviates(), q3::PlanewavePseudopotentialKohnShamSCFIterator::write_checkpoints(), q3::BerkeleyGWChargeDensityFile::write_to_file(), q3::BerkeleyGWExchangeCorrelationFile::write_to_file(), q3::BerkeleyGWWavefunctionFile::write_to_file(), q3::QEPlanewaveKohnShamChargeDensityCheckpoint::write_to_file(), and q3::QEPlanewaveKohnShamWavefunctionCheckpoint::write_to_file().