libadc-cxx 1.0.0
Structured logging for scientific computing
Loading...
Searching...
No Matches
utility.hpp
Go to the documentation of this file.
1/* Copyright 2025 NTESS. See the top-level LICENSE.txt file for details.
2 *
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5#ifndef adc_utility_hpp
6#define adc_utility_hpp
7#include <string>
8#include <string_view>
9#include <map>
10#include <set>
11
12namespace adc {
13
14/** \addtogroup API
15 * @{
16 */
17inline version adc_utility_version("1.0.0", {"none"});
18
19/*! Utility to get output directory glob pattern from the multifile_publisher, given the
20 * ADC_MULTIFILE_DIRECTORY and ADC_WFID values in use or their library-prefixed-versions.
21 */
22ADC_VISIBLE std::string get_multifile_log_path(std::string_view dir, std::string_view wfid);
23
24/*! Utility to merge parallel outputs from multifile publisher.
25 * Consolidation should only happen after the multifile publisher is finalized;
26 * If a multi_publisher is in use, consolidation should only happen after
27 * terminate has been called on the multi_publisher (which calls finalize).
28 * On slow nfs-based file systems, some delay may be needed to ensure all
29 * files are seen on the aggregating client.
30 * \param match the result of an appropriate call to get_multifile_log_path.
31 * \param old_paths the names of files that were successfully merged. May be empty;
32 * if not empty, deleting the files in the list is recommended.
33 *
34 * \return the list of new consolidated logs from reduction of a multifile publisher tree.
35 *
36 * Example:
37 * /FS/adc/ may be multiuser
38 * /FS/adc/$user is owned/writable by $user
39 * /FS/adc/$user/$adc_wfid.* are created to prevent output conflicts, and then consolidated
40 * to:
41 * /FS/adc/$user/consolidated.$adc_wfid.adct-json.multi.xml
42 * Where ADC_WFID is not defined, a timestamp is used in its place.
43 */
44ADC_VISIBLE std::vector< std::string > consolidate_multifile_logs(const std::string& match, std::vector< std::string>& old_paths, bool debug=false);
45
46/*! Utility to validate that multi-record files were correctly written.
47 * Each record is a json object delimited by <adct-json></adct-json> xml tags.
48 * \return vector of the start positions of invalid records.
49 * \param filename input to check.
50 * \param check_json validates that individual record contents are json formatted (but does not
51 * check adct schema compliance).
52 * \param count output of number of valid records found.
53 *
54 * <adc-json> tags cannot be nested. Unclosed tags are assumed closed by the start of the next record.
55 *
56 * BUGS:
57 * not yet implemented. returns emtpy vector and 0 record_count until implemented.
58 */
59ADC_VISIBLE std::vector<size_t> validate_multifile_log(std::string_view filename, bool check_json, size_t & record_count);
60/** @}*/
61} // namespace adc
62#endif // adc_utility_hpp
version adc_utility_version("1.0.0", {"none"})
ADC_VISIBLE std::vector< size_t > validate_multifile_log(string_view filename, bool check_json, size_t &record_count)
Definition utility.ipp:42
ADC_VISIBLE std::string get_multifile_log_path(string_view dir, string_view wfid)
Definition utility.ipp:37
ADC_VISIBLE std::vector< std::string > consolidate_multifile_logs(const std::string &match, std::vector< std::string > &old_paths, bool debug=false)
Definition utility.ipp:29
Definition adc.hpp:82
A version with tags list.
Definition types.hpp:28