CASM  1.1.0
A Clusters Approach to Statistical Mechanics
CASM::FixedLog Class Reference

#include <Log.hh>

+ Inheritance diagram for CASM::FixedLog:

Detailed Description

A Log whose underlying ostream* cannot be reset.

Definition at line 404 of file Log.hh.

Public Member Functions

 FixedLog (std::ostream &_ostream)
 
 FixedLog (FixedLog const &)=delete
 
FixedLogoperator= (FixedLog const &RHS)=delete
 
template<int _required_verbosity = standard>
void calculate (const std::string &what)
 
template<int _required_verbosity = standard>
void construct (const std::string &what)
 
template<int _required_verbosity = standard>
void generate (const std::string &what)
 
template<int _required_verbosity = standard>
void set (const std::string &what)
 
template<int _required_verbosity = standard>
void check (const std::string &what)
 
template<int _required_verbosity = standard>
void results (const std::string &what)
 
template<int _required_verbosity = standard>
void read (const std::string &what)
 
template<int _required_verbosity = standard>
void write (const std::string &what)
 
template<int _required_verbosity = standard>
void begin (const std::string &what)
 
template<int _required_verbosity = standard>
void end (const std::string &what)
 
template<int _required_verbosity = standard>
void warning (const std::string &what)
 
template<int _required_verbosity = standard>
void error (const std::string &what)
 
template<int _required_verbosity = standard>
void compiling (const std::string &what)
 
template<int _required_verbosity = standard>
void custom (const std::string &what)
 
template<int _required_verbosity = standard>
void custom (const std::string &type, const std::string &what)
 
template<int _required_verbosity = standard>
void begin_section ()
 Begin a section, without header. More...
 
Logsubsection ()
 Create a subsection. More...
 
void end_section ()
 End a section. More...
 
void restart_clock ()
 
void show_clock ()
 
void hide_clock ()
 
double time_s () const
 
void begin_lap ()
 
double lap_time () const
 
int verbosity () const
 
void set_verbosity (int _verbosity)
 
template<int _required_verbosity>
Logrequire ()
 
void reset (std::ostream &_ostream=std::cout)
 
void set_width (int width)
 
int width () const
 
void set_justification (JustificationType justification)
 
JustificationType justification ()
 
Logparagraph (std::string text)
 Print indented paragraph with wrapping at Log::width() More...
 
Logverbatim (std::string text, bool indent_first_line=true)
 Print verbatim, but with indentation (optional on first line) More...
 
template<typename OutputIterator >
Logverbatim_list (OutputIterator begin, OutputIterator end, std::string sep="- ")
 Print a list. More...
 
 operator std::ostream & ()
 
std::ostream & ostream ()
 
bool print () const
 
 operator bool ()
 
int indent_space () const
 
std::string indent_str () const
 
void increase_indent ()
 
void decrease_indent ()
 
void increase_indent_spaces (int n)
 
void decrease_indent_spaces (int n)
 
Logindent ()
 
template<typename T >
Logindent (const T &t)
 Same as verbatim, but uses stringstream to convert to string first. More...
 

Static Public Member Functions

static std::string invalid_verbosity_msg (std::string s)
 
static std::pair< bool, int > verbosity_level (std::string s)
 Read verbosity level from a string. More...
 

Static Public Attributes

static const int none = 0
 
static const int quiet = 5
 
static const int standard = 10
 
static const int verbose = 20
 
static const int debug = 100
 

Private Member Functions

void reset (std::ostream &_ostream=std::cout)
 
template<int _required_verbosity = standard>
void _add (const std::string &type, const std::string &what)
 
void _print_justified_line (std::vector< std::string > &line, int curr_width)
 
void _print_left_justified_line (std::vector< std::string > &line, int curr_width)
 
void _print_right_justified_line (std::vector< std::string > &line, int curr_width)
 
void _print_center_justified_line (std::vector< std::string > &line, int curr_width)
 
void _print_full_justified_line (std::vector< std::string > &line, int curr_width)
 
void _add_time ()
 
bool _print () const
 

Private Attributes

std::vector< int > m_required_verbosity
 
int m_verbosity
 If m_verbosity >= required verbosity, then print. More...
 
bool m_print
 Whether to print. More...
 
bool m_show_clock
 
int m_indent_space
 indent_str = m_indent_space*m_indent_level + m_indent_spaces More...
 
int m_indent_level
 
int m_indent_spaces
 
int m_paragraph_width
 
JustificationType m_justification
 
boost::chrono::steady_clock::time_point m_start_time
 
boost::chrono::steady_clock::time_point m_lap_start_time
 
std::ostream * m_ostream
 

Constructor & Destructor Documentation

◆ FixedLog() [1/2]

CASM::FixedLog::FixedLog ( std::ostream &  _ostream)
explicit

Definition at line 277 of file Log.cc.

◆ FixedLog() [2/2]

CASM::FixedLog::FixedLog ( FixedLog const &  )
delete

Member Function Documentation

◆ _add()

template<int _required_verbosity = standard>
void CASM::Log::_add ( const std::string &  type,
const std::string &  what 
)
inlineprivateinherited

Definition at line 309 of file Log.hh.

◆ _add_time()

void CASM::Log::_add_time ( )
privateinherited

Definition at line 262 of file Log.cc.

◆ _print()

bool CASM::Log::_print ( ) const
privateinherited

Definition at line 268 of file Log.cc.

◆ _print_center_justified_line()

void CASM::Log::_print_center_justified_line ( std::vector< std::string > &  line,
int  curr_width 
)
privateinherited

Definition at line 126 of file Log.cc.

◆ _print_full_justified_line()

void CASM::Log::_print_full_justified_line ( std::vector< std::string > &  line,
int  curr_width 
)
privateinherited

Definition at line 142 of file Log.cc.

◆ _print_justified_line()

void CASM::Log::_print_justified_line ( std::vector< std::string > &  line,
int  curr_width 
)
privateinherited

Definition at line 81 of file Log.cc.

◆ _print_left_justified_line()

void CASM::Log::_print_left_justified_line ( std::vector< std::string > &  line,
int  curr_width 
)
privateinherited

Definition at line 98 of file Log.cc.

◆ _print_right_justified_line()

void CASM::Log::_print_right_justified_line ( std::vector< std::string > &  line,
int  curr_width 
)
privateinherited

Definition at line 110 of file Log.cc.

◆ begin()

template<int _required_verbosity = standard>
void CASM::Log::begin ( const std::string &  what)
inlineinherited

Definition at line 114 of file Log.hh.

◆ begin_lap()

void CASM::Log::begin_lap ( )
inherited

Definition at line 47 of file Log.cc.

◆ begin_section()

template<int _required_verbosity = standard>
void CASM::Log::begin_section ( )
inlineinherited

Begin a section, without header.

Definition at line 158 of file Log.hh.

◆ calculate()

template<int _required_verbosity = standard>
void CASM::Log::calculate ( const std::string &  what)
inlineinherited

Definition at line 74 of file Log.hh.

◆ check()

template<int _required_verbosity = standard>
void CASM::Log::check ( const std::string &  what)
inlineinherited

Definition at line 94 of file Log.hh.

◆ compiling()

template<int _required_verbosity = standard>
void CASM::Log::compiling ( const std::string &  what)
inlineinherited

Definition at line 134 of file Log.hh.

◆ construct()

template<int _required_verbosity = standard>
void CASM::Log::construct ( const std::string &  what)
inlineinherited

Definition at line 79 of file Log.hh.

◆ custom() [1/2]

template<int _required_verbosity = standard>
void CASM::Log::custom ( const std::string &  type,
const std::string &  what 
)
inlineinherited

Definition at line 152 of file Log.hh.

◆ custom() [2/2]

template<int _required_verbosity = standard>
void CASM::Log::custom ( const std::string &  what)
inlineinherited

Definition at line 139 of file Log.hh.

◆ decrease_indent()

void CASM::Log::decrease_indent ( )
inlineinherited

Definition at line 279 of file Log.hh.

◆ decrease_indent_spaces()

void CASM::Log::decrease_indent_spaces ( int  n)
inlineinherited

Definition at line 287 of file Log.hh.

◆ end()

template<int _required_verbosity = standard>
void CASM::Log::end ( const std::string &  what)
inlineinherited

Definition at line 119 of file Log.hh.

◆ end_section()

void CASM::Log::end_section ( )
inlineinherited

End a section.

Definition at line 192 of file Log.hh.

◆ error()

template<int _required_verbosity = standard>
void CASM::Log::error ( const std::string &  what)
inlineinherited

Definition at line 129 of file Log.hh.

◆ generate()

template<int _required_verbosity = standard>
void CASM::Log::generate ( const std::string &  what)
inlineinherited

Definition at line 84 of file Log.hh.

◆ hide_clock()

void CASM::Log::hide_clock ( )
inherited

Definition at line 39 of file Log.cc.

◆ increase_indent()

void CASM::Log::increase_indent ( )
inlineinherited

Definition at line 277 of file Log.hh.

◆ increase_indent_spaces()

void CASM::Log::increase_indent_spaces ( int  n)
inlineinherited

Definition at line 285 of file Log.hh.

◆ indent() [1/2]

Log& CASM::Log::indent ( )
inlineinherited

Definition at line 289 of file Log.hh.

◆ indent() [2/2]

template<typename T >
Log& CASM::Log::indent ( const T &  t)
inlineinherited

Same as verbatim, but uses stringstream to convert to string first.

Definition at line 296 of file Log.hh.

◆ indent_space()

int CASM::Log::indent_space ( ) const
inlineinherited

Definition at line 271 of file Log.hh.

◆ indent_str()

std::string CASM::Log::indent_str ( ) const
inlineinherited

Definition at line 273 of file Log.hh.

◆ invalid_verbosity_msg()

std::string CASM::Log::invalid_verbosity_msg ( std::string  s)
staticinherited

Definition at line 219 of file Log.cc.

◆ justification()

JustificationType CASM::Log::justification ( )
inlineinherited

Definition at line 240 of file Log.hh.

◆ lap_time()

double CASM::Log::lap_time ( ) const
inherited

Definition at line 49 of file Log.cc.

◆ operator bool()

CASM::Log::operator bool ( )
inlineexplicitinherited

Definition at line 266 of file Log.hh.

◆ operator std::ostream &()

CASM::Log::operator std::ostream & ( )
inherited

Definition at line 217 of file Log.cc.

◆ operator=()

FixedLog& CASM::FixedLog::operator= ( FixedLog const &  RHS)
delete

◆ ostream()

std::ostream& CASM::Log::ostream ( )
inlineinherited

Definition at line 262 of file Log.hh.

◆ paragraph()

Log & CASM::Log::paragraph ( std::string  text)
inherited

Print indented paragraph with wrapping at Log::width()

Definition at line 168 of file Log.cc.

◆ print()

bool CASM::Log::print ( ) const
inherited

Definition at line 260 of file Log.cc.

◆ read()

template<int _required_verbosity = standard>
void CASM::Log::read ( const std::string &  what)
inlineinherited

Definition at line 104 of file Log.hh.

◆ require()

template<int _required_verbosity>
Log& CASM::Log::require ( )
inlineinherited

Definition at line 221 of file Log.hh.

◆ reset() [1/2]

void CASM::Log::reset ( std::ostream &  _ostream = std::cout)
inherited

Definition at line 59 of file Log.cc.

◆ reset() [2/2]

void CASM::Log::reset
private

Definition at line 228 of file Log.cc.

◆ restart_clock()

void CASM::Log::restart_clock ( )
inherited

Definition at line 35 of file Log.cc.

◆ results()

template<int _required_verbosity = standard>
void CASM::Log::results ( const std::string &  what)
inlineinherited

Definition at line 99 of file Log.hh.

◆ set()

template<int _required_verbosity = standard>
void CASM::Log::set ( const std::string &  what)
inlineinherited

Definition at line 89 of file Log.hh.

◆ set_justification()

void CASM::Log::set_justification ( JustificationType  justification)
inlineinherited

Definition at line 236 of file Log.hh.

◆ set_verbosity()

void CASM::Log::set_verbosity ( int  _verbosity)
inherited

Definition at line 57 of file Log.cc.

◆ set_width()

void CASM::Log::set_width ( int  width)
inlineinherited

Definition at line 232 of file Log.hh.

◆ show_clock()

void CASM::Log::show_clock ( )
inherited

Definition at line 37 of file Log.cc.

◆ subsection()

Log& CASM::Log::subsection ( )
inlineinherited

Create a subsection.

  • Note creates a subsection, but remembers the previous section, so that when 'end_section' is called the previous section's verbosity level becomes active again.

Example:

log.begin("Section A");
log << stuff << std::endl;
log << std::endl;
log.subsection().begin("Section A.1");
log << indent_str() << subsection_stuff << std::endl;
log << std::endl;
log << "continue in section A" << std::endl;
log << std::endl;
std::string indent_str() const
Definition: Log.hh:273
void end_section()
End a section.
Definition: Log.hh:192
Log & subsection()
Create a subsection.
Definition: Log.hh:186
void begin(const std::string &what)
Definition: Log.hh:114
void increase_indent()
Definition: Log.hh:277
void decrease_indent()
Definition: Log.hh:279
Log & log()
Definition: Log.hh:424

Definition at line 186 of file Log.hh.

◆ time_s()

double CASM::Log::time_s ( ) const
inherited

Definition at line 41 of file Log.cc.

◆ verbatim()

Log & CASM::Log::verbatim ( std::string  text,
bool  indent_first_line = true 
)
inherited

Print verbatim, but with indentation (optional on first line)

Definition at line 201 of file Log.cc.

◆ verbatim_list()

template<typename OutputIterator >
Log & CASM::Log::verbatim_list ( OutputIterator  begin,
OutputIterator  end,
std::string  sep = "- " 
)
inherited

Print a list.

  • Prints each element in vector to a stringstream, then uses Log::verbatim to print into the list.
  • Indentation is set to the length of the "sep" string

Example, with initial indent of 2 spaces, and sep="-- ":

A list:
-- first value
-- some value
that prints
on multiple lines
-- last value

Definition at line 377 of file Log.hh.

◆ verbosity()

int CASM::Log::verbosity ( ) const
inherited

Definition at line 55 of file Log.cc.

◆ verbosity_level()

std::pair< bool, int > CASM::Log::verbosity_level ( std::string  s)
staticinherited

Read verbosity level from a string.

Returns
result, a pair of bool,int result.first == true if successfully read, and result.second is the verbosity level

Definition at line 231 of file Log.cc.

◆ warning()

template<int _required_verbosity = standard>
void CASM::Log::warning ( const std::string &  what)
inlineinherited

Definition at line 124 of file Log.hh.

◆ width()

int CASM::Log::width ( ) const
inlineinherited

Definition at line 234 of file Log.hh.

◆ write()

template<int _required_verbosity = standard>
void CASM::Log::write ( const std::string &  what)
inlineinherited

Definition at line 109 of file Log.hh.

Member Data Documentation

◆ debug

const int CASM::Log::debug = 100
staticinherited

Definition at line 54 of file Log.hh.

◆ m_indent_level

int CASM::Log::m_indent_level
privateinherited

Definition at line 347 of file Log.hh.

◆ m_indent_space

int CASM::Log::m_indent_space
privateinherited

indent_str = m_indent_space*m_indent_level + m_indent_spaces

Definition at line 346 of file Log.hh.

◆ m_indent_spaces

int CASM::Log::m_indent_spaces
privateinherited

Definition at line 348 of file Log.hh.

◆ m_justification

JustificationType CASM::Log::m_justification
privateinherited

Definition at line 352 of file Log.hh.

◆ m_lap_start_time

boost::chrono::steady_clock::time_point CASM::Log::m_lap_start_time
privateinherited

Definition at line 356 of file Log.hh.

◆ m_ostream

std::ostream* CASM::Log::m_ostream
privateinherited

Definition at line 358 of file Log.hh.

◆ m_paragraph_width

int CASM::Log::m_paragraph_width
privateinherited

Definition at line 351 of file Log.hh.

◆ m_print

bool CASM::Log::m_print
privateinherited

Whether to print.

Definition at line 341 of file Log.hh.

◆ m_required_verbosity

std::vector<int> CASM::Log::m_required_verbosity
privateinherited

Definition at line 335 of file Log.hh.

◆ m_show_clock

bool CASM::Log::m_show_clock
privateinherited

Definition at line 343 of file Log.hh.

◆ m_start_time

boost::chrono::steady_clock::time_point CASM::Log::m_start_time
privateinherited

Definition at line 354 of file Log.hh.

◆ m_verbosity

int CASM::Log::m_verbosity
privateinherited

If m_verbosity >= required verbosity, then print.

Definition at line 338 of file Log.hh.

◆ none

const int CASM::Log::none = 0
staticinherited

Definition at line 50 of file Log.hh.

◆ quiet

const int CASM::Log::quiet = 5
staticinherited

Definition at line 51 of file Log.hh.

◆ standard

const int CASM::Log::standard = 10
staticinherited

Definition at line 52 of file Log.hh.

◆ verbose

const int CASM::Log::verbose = 20
staticinherited

Definition at line 53 of file Log.hh.


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