LBANN  0.103.0
LivermoreBigArtificialNeuralNetworkToolkit
output_helpers.hpp
Go to the documentation of this file.
1 // Copyright (c) 2014-2023, Lawrence Livermore National Security, LLC.
3 // Produced at the Lawrence Livermore National Laboratory.
4 // Written by the LBANN Research Team (B. Van Essen, et al.) listed in
5 // the CONTRIBUTORS file. <lbann-dev@llnl.gov>
6 //
7 // LLNL-CODE-697807.
8 // All rights reserved.
9 //
10 // This file is part of LBANN: Livermore Big Artificial Neural Network
11 // Toolkit. For details, see http://software.llnl.gov/LBANN or
12 // https://github.com/LLNL/LBANN.
13 //
14 // Licensed under the Apache License, Version 2.0 (the "Licensee"); you
15 // may not use this file except in compliance with the License. You may
16 // obtain a copy of the License at:
17 //
18 // http://www.apache.org/licenses/LICENSE-2.0
19 //
20 // Unless required by applicable law or agreed to in writing, software
21 // distributed under the License is distributed on an "AS IS" BASIS,
22 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
23 // implied. See the License for the specific language governing
24 // permissions and limitations under the license.
26 #ifndef LBANN_UTILS_OUTPUT_HELPERS_HPP_INCLUDED
27 #define LBANN_UTILS_OUTPUT_HELPERS_HPP_INCLUDED
28 
29 #include <iostream>
30 
31 namespace lbann {
32 
36 bool is_good_terminal(std::ostream& os) noexcept;
37 
50 std::pair<unsigned short, unsigned short>
51 get_window_size(std::ostream& os) noexcept;
52 
56 std::string truncate_to_width(std::string const& str, size_t max_len);
57 
71 
74 std::string strip_ansi_csis(std::string const& input);
75 
77 std::ostream& black(std::ostream&);
78 
80 std::ostream& red(std::ostream&);
81 
83 std::ostream& green(std::ostream&);
84 
86 std::ostream& yellow(std::ostream&);
87 
89 std::ostream& blue(std::ostream&);
90 
92 std::ostream& magenta(std::ostream&);
93 
95 std::ostream& cyan(std::ostream&);
96 
98 std::ostream& white(std::ostream&);
99 
101 std::ostream& bgblack(std::ostream&);
102 
104 std::ostream& bgred(std::ostream&);
105 
107 std::ostream& bggreen(std::ostream&);
108 
110 std::ostream& bgyellow(std::ostream&);
111 
113 std::ostream& bgblue(std::ostream&);
114 
116 std::ostream& bgmagenta(std::ostream&);
117 
119 std::ostream& bgcyan(std::ostream&);
120 
122 std::ostream& bgwhite(std::ostream&);
123 
125 std::ostream& nocolor(std::ostream&);
126 
128 std::ostream& clearline(std::ostream&);
129 
131 
132 } // namespace lbann
133 
134 #endif // LBANN_UTILS_OUTPUT_HELPERS_HPP_INCLUDED
std::ostream & bgmagenta(std::ostream &)
Turn the ANSI background color output magenta.
std::ostream & blue(std::ostream &)
Turn the ANSI foreground color output blue.
std::string strip_ansi_csis(std::string const &input)
Remove ANSI CSIs from the string.
std::ostream & clearline(std::ostream &)
Clear remaining characters in the line.
std::ostream & cyan(std::ostream &)
Turn the ANSI foreground color output cyan.
std::pair< unsigned short, unsigned short > get_window_size(std::ostream &os) noexcept
Gets the dimensions of the terminal, if available.
std::ostream & magenta(std::ostream &)
Turn the ANSI foreground color output magenta.
std::ostream & bgcyan(std::ostream &)
Turn the ANSI background color output cyan.
std::ostream & green(std::ostream &)
Turn the ANSI foreground color output green.
std::ostream & black(std::ostream &)
Turn the ANSI foreground color output black.
std::ostream & bggreen(std::ostream &)
Turn the ANSI background color output green.
std::ostream & bgblue(std::ostream &)
Turn the ANSI background color output blue.
std::ostream & white(std::ostream &)
Turn the ANSI foreground color output white.
std::ostream & bgred(std::ostream &)
Turn the ANSI background color output red.
std::string truncate_to_width(std::string const &str, size_t max_len)
A simple utility to replace the tail end of a long string with an ellipsis.
std::ostream & bgyellow(std::ostream &)
Turn the ANSI background color output yellow.
std::ostream & bgwhite(std::ostream &)
Turn the ANSI background color output white.
bool is_good_terminal(std::ostream &os) noexcept
Roughly determines if the stream points to a nice terminal (is a terminal, supports color)...
std::ostream & bgblack(std::ostream &)
Turn the ANSI background color output black.
std::ostream & nocolor(std::ostream &)
Reset the ANSI color to the default.
std::ostream & red(std::ostream &)
Turn the ANSI foreground color output red.
std::ostream & yellow(std::ostream &)
Turn the ANSI foreground color output yellow.