1#ifndef VIENNASHE_LOG_LOG_HPP
2#define VIENNASHE_LOG_LOG_HPP
60 if (setter) current_level = new_level;
74 template <
bool enabled >
78 typedef std::ostringstream CollectorStreamType;
79 CollectorStreamType local_out;
94 this->
get() <<
"[" << component_name <<
"] ";
100 this->
get() <<
"[" << component_name <<
"] ";
104 if (
do_log() ){local_out.str(r.local_out.str());}
111#ifndef VIENNASHE_LOG_DISABLE
114 #ifdef VIENNASHE_LOG_ENABLE_FANCY_BASH
115 switch(_messageLevel)
118 #ifdef VIENNASHE_LOG_ATOMIC
119 fprintf(stderr,
"\033[1;31m %s \033[0m",
get().str().c_str());
122 std::cout <<
get().str();
126 #ifdef VIENNASHE_LOG_ATOMIC
127 fprintf(stdout,
"\033[1;33m %s \033[0m",
get().str().c_str());
130 std::cout <<
get().str();
134 #ifdef VIENNASHE_LOG_ATOMIC
135 fprintf(stdout,
"\033[1;32m %s \033[0m",
get().str().c_str());
138 std::cout <<
get().str();
142 #ifdef VIENNASHE_LOG_ATOMIC
143 fprintf(stdout,
"%s",
get().str().c_str());
146 std::cout <<
get().str();
151 #ifdef VIENNASHE_LOG_ATOMIC
152 fprintf(stdout,
"%s",
get().str().c_str());
155 std::cout <<
get().str();
166 CollectorStreamType &
get() {
return local_out; }
168 CollectorStreamType
const &
get()
const {
return local_out; }
171 template <
typename T>
178 typedef std::ostream& (*ostream_manipulator)(std::ostream&);
240 template <
typename T>
243 typedef std::ostream& (*ostream_manipulator)(std::ostream&);
256#ifndef VIENNASHE_LOG_DISABLE
258 template <
typename KeyTypeT >
264 template < log_levels level,
typename KeyTypeT >
270 template < log_levels level >
277 template <
typename KeyTypeT >
283 template < log_levels level,
typename KeyTypeT >
289 template < log_levels level >
290 nullstream &
vlogL( )
298#ifndef VIENNASHE_LOG_DISABLE
315 template <
typename KeyTypeT >
320 template <
typename KeyTypeT >
325 template <
typename KeyTypeT >
330 template <
typename KeyTypeT >
335 template <
typename KeyTypeT >
340 inline nullstream &
error() {
return detail::vlogL<logERROR>(); }
341 inline nullstream &
warn() {
return detail::vlogL<logWARNING>(); }
342 inline nullstream &
warning() {
return detail::vlogL<logWARNING>(); }
343 inline nullstream &
info() {
return detail::vlogL<logINFO>(); }
344 inline nullstream &
debug() {
return detail::vlogL<logDEBUG>(); }
346 template <
typename KeyTypeT >
347 nullstream &
error() {
return detail::vlogTL<logERROR, KeyTypeT>(); }
349 template <
typename KeyTypeT >
350 nullstream &
warn() {
return detail::vlogTL<logWARNING, KeyTypeT>(); }
352 template <
typename KeyTypeT >
353 nullstream &
warning() {
return detail::vlogTL<logWARNING, KeyTypeT>(); }
355 template <
typename KeyTypeT >
356 nullstream &
info() {
return detail::vlogTL<logINFO, KeyTypeT>(); }
358 template <
typename KeyTypeT >
359 nullstream &
debug() {
return detail::vlogTL<logDEBUG, KeyTypeT>(); }
nullstream & operator<<(std::string &)
nullstream & operator<<(const T &)
logger(log_levels level, const std::string &)
logger(const std::string &)
nullstream & operator<<(logger &)
nullstream & operator<<(ostream_manipulator)
nullstream & operator<<(const std::string &)
nullstream const & get() const
nullstream & operator<<(const char *)
The Main logger class. Assembles output lines and writes them to std::cout upon destruction.
CollectorStreamType & operator<<(logger &r)
~logger()
Destructor. Does actually write the log-message to the output-stream (normally std::cout)
CollectorStreamType & get()
Returns the collector stream to collect the output.
CollectorStreamType & operator<<(const T &x)
Generic shift left operator to print stuff via the logger.
CollectorStreamType & operator<<(std::string &x)
CollectorStreamType & operator<<(const char *x)
CollectorStreamType const & get() const
Returns the collector stream to collect the output.
std::ostream &(* ostream_manipulator)(std::ostream &)
CollectorStreamType & operator<<(const std::string &x)
logger(log_levels level, const std::string &component_name)
CTOR to log componentwise on a certain log-level. Adds [component_name] to the start of every log-lin...
logger(const std::string &component_name)
CTOR to log componentwise. Adds [component_name] to the start of every log-line.
bool do_log() const
Returns true if the log-level is smaller than the globally set one.
CollectorStreamType & operator<<(ostream_manipulator pf)
logger< KeyTypeT::enabled > vlogT()
logger< KeyTypeT::enabled > vlogTL()
log_levels
Defines various log-levels. Note that log levels are inclusive, i.e. log levels with larger number in...
@ logWARNING
logger outputs errors only
@ logDEBUG
logger outputs errors, warnings and status information
@ logINFO
logger outputs errors and warnings
@ logNEVER
logger outputs lots of debug infos as well
logger< true > error()
Used to log errors. The logging level is logERROR.
nullstream & get_nullstream()
Singleton factory for nullstream.
logger< true > debug()
Used to log debug output. The logging level is logDEBUG.
log_levels log_level()
Getter for the global log level.
void set_log_level(log_levels new_level)
Sets the global log level.
logger< true > warning()
Used to log warnings. The logging level is logWARNING.
logger< true > warn()
Used to log warnings. The logging level is logWARNING.
logger< true > info()
Used to log infos. The logging level is logINFO.
The main ViennaSHE namespace. All functionality resides inside this namespace.
Provides a streamer which discards all inputs. Similar in effect to a redirection to /dev/null....
Streaming class which only provides operator<< discarding the right hand side.