DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DNDS::CsvLog Class Reference

Append-only CSV logger with automatic file rotation after a line-count limit. More...

#include <CsvLog.hpp>

Public Member Functions

template<class T_titles >
 CsvLog (T_titles &&n_titles, std::unique_ptr< std::ostream > n_pOs)
 Construct a logger with externally-provided titles and output stream.
 
template<class T_titles >
 CsvLog (T_titles &&n_titles, const std::string &n_log_name_bare, const std::string &n_log_name_suffix=".csv", int64_t n_n_line_max=10000)
 Construct a logger that creates / manages its own output files.
 
template<class TMap >
void WriteLine (TMap &&title_to_value, int nPrecision)
 Append one CSV row by looking up each column in title_to_value.
 
void WriteTitle ()
 Emit the title row (called automatically on the first WriteLine).
 

Detailed Description

Append-only CSV logger with automatic file rotation after a line-count limit.

One instance writes rows to a file, using a caller-provided ordered list of column titles. After n_line_max rows the output is rotated to <bare>_<block>.suffix to keep any single file size bounded.

Typical use: one CsvLog per solver per rank-0 process, recording per-iteration diagnostics with LogSimpleDIValue entries keyed by title.

Definition at line 65 of file CsvLog.hpp.

Constructor & Destructor Documentation

◆ CsvLog() [1/2]

template<class T_titles >
DNDS::CsvLog::CsvLog ( T_titles &&  n_titles,
std::unique_ptr< std::ostream >  n_pOs 
)
inline

Construct a logger with externally-provided titles and output stream.

Definition at line 87 of file CsvLog.hpp.

◆ CsvLog() [2/2]

template<class T_titles >
DNDS::CsvLog::CsvLog ( T_titles &&  n_titles,
const std::string &  n_log_name_bare,
const std::string &  n_log_name_suffix = ".csv",
int64_t  n_n_line_max = 10000 
)
inline

Construct a logger that creates / manages its own output files.

Parameters
n_titlesColumn titles (ordered).
n_log_name_bareBase path without suffix, e.g. "out/run".
n_log_name_suffixFilename suffix including dot (default ".csv").
n_n_line_maxRotate to a new file every this many lines.

Definition at line 96 of file CsvLog.hpp.

Member Function Documentation

◆ WriteLine()

template<class TMap >
void DNDS::CsvLog::WriteLine ( TMap &&  title_to_value,
int  nPrecision 
)
inline

Append one CSV row by looking up each column in title_to_value.

Template Parameters
TMapMap-like supporting operator[](std::string) returning something streamable.
Parameters
nPrecisionDecimal digits used for floating-point output.

Definition at line 113 of file CsvLog.hpp.

Here is the call graph for this function:

◆ WriteTitle()

void DNDS::CsvLog::WriteTitle ( )
inline

Emit the title row (called automatically on the first WriteLine).

Definition at line 132 of file CsvLog.hpp.

Here is the caller graph for this function:

The documentation for this class was generated from the following file: