List of all members | Classes | Static Public Member Functions | Static Public Attributes
casadi::Logger Class Reference

Keeps track of logging output to screen and/or files. More...

#include <casadi_logger.hpp>

Detailed Description

All printout from CasADi routines should go through this files.

Author
Joel Andersson
Date
2015

Extra doc: https://github.com/casadi/casadi/wiki/L_23u

Definition at line 44 of file casadi_logger.hpp.

Classes

class  Stream
 
class  Streambuf
 

Static Public Member Functions

static void WriteFunThreadSafe (const char *s, std::streamsize num, bool error)
 
static void FlushThreadSafe (bool error)
 
static void writeDefault (const char *s, std::streamsize num, bool error)
 By default, print to std::cout or std::cerr. More...
 
static void flushDefault (bool error)
 By default, flush std::cout or std::cerr. More...
 
static void writeIgnore (const char *s, std::streamsize num, bool error)
 Ignore output. More...
 
template<bool Err>
static void write (const char *s, std::streamsize num)
 Print output message. More...
 
template<bool Err>
static void writeCh (char ch)
 Print log message, single character. More...
 

Static Public Attributes

static void(* writeFun )(const char *s, std::streamsize num, bool error)
 Print warnings, can be redefined. More...
 
static void(* flush )(bool error) =Logger::flushDefault
 Flush buffers. More...
 

Member Function Documentation

◆ flushDefault()

static void casadi::Logger::flushDefault ( bool  error)
inlinestatic

Definition at line 69 of file casadi_logger.hpp.

69  {
70  if (error) {
71  std::cerr << std::flush;
72  } else {
73  std::cout << std::flush;
74  }
75  }

◆ FlushThreadSafe()

void casadi::Logger::FlushThreadSafe ( bool  error)
static

Definition at line 49 of file casadi_logger.cpp.

49  {
50 #ifdef CASADI_WITH_THREAD
51  std::lock_guard<std::mutex> lock(mutex_logger);
52 #endif //CASADI_WITH_THREAD
53  flush(error);
54  }
static void(* flush)(bool error)
Flush buffers.

References flush.

◆ write()

template<bool Err>
static void casadi::Logger::write ( const char *  s,
std::streamsize  num 
)
inlinestatic

Definition at line 82 of file casadi_logger.hpp.

82  {
83  // All information
84  WriteFunThreadSafe(s, num, Err);
85  }
static void WriteFunThreadSafe(const char *s, std::streamsize num, bool error)

◆ writeCh()

template<bool Err>
static void casadi::Logger::writeCh ( char  ch)
inlinestatic

Definition at line 88 of file casadi_logger.hpp.

88  {
89  write<Err>(&ch, 1);
90  }

◆ writeDefault()

static void casadi::Logger::writeDefault ( const char *  s,
std::streamsize  num,
bool  error 
)
inlinestatic

Definition at line 60 of file casadi_logger.hpp.

60  {
61  if (error) {
62  std::cerr.write(s, num);
63  } else {
64  std::cout.write(s, num);
65  }
66  }

◆ WriteFunThreadSafe()

void casadi::Logger::WriteFunThreadSafe ( const char *  s,
std::streamsize  num,
bool  error 
)
static

Definition at line 42 of file casadi_logger.cpp.

42  {
43 #ifdef CASADI_WITH_THREAD
44  std::lock_guard<std::mutex> lock(mutex_logger);
45 #endif //CASADI_WITH_THREAD
46  writeFun(s, num, error);
47  }
static void(* writeFun)(const char *s, std::streamsize num, bool error)
Print warnings, can be redefined.

References writeFun.

◆ writeIgnore()

static void casadi::Logger::writeIgnore ( const char *  s,
std::streamsize  num,
bool  error 
)
inlinestatic

Definition at line 78 of file casadi_logger.hpp.

78  {
79  }

Member Data Documentation

◆ flush

void(* casadi::Logger::flush)(bool error) =Logger::flushDefault
static

Definition at line 54 of file casadi_logger.hpp.

Referenced by FlushThreadSafe().

◆ writeFun

void(* casadi::Logger::writeFun)(const char *s, std::streamsize num, bool error)
static
Initial value:
=
static void writeDefault(const char *s, std::streamsize num, bool error)
By default, print to std::cout or std::cerr.

Definition at line 51 of file casadi_logger.hpp.

Referenced by WriteFunThreadSafe().


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